specweave 0.24.6 → 0.24.8

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 (147) hide show
  1. package/CLAUDE.md +64 -0
  2. package/README.md +34 -0
  3. package/dist/src/cli/helpers/issue-tracker/github-multi-repo.d.ts +5 -2
  4. package/dist/src/cli/helpers/issue-tracker/github-multi-repo.d.ts.map +1 -1
  5. package/dist/src/cli/helpers/issue-tracker/github-multi-repo.js +72 -6
  6. package/dist/src/cli/helpers/issue-tracker/github-multi-repo.js.map +1 -1
  7. package/dist/src/cli/helpers/issue-tracker/github.d.ts +2 -1
  8. package/dist/src/cli/helpers/issue-tracker/github.d.ts.map +1 -1
  9. package/dist/src/cli/helpers/issue-tracker/github.js +4 -3
  10. package/dist/src/cli/helpers/issue-tracker/github.js.map +1 -1
  11. package/dist/src/cli/helpers/issue-tracker/index.d.ts.map +1 -1
  12. package/dist/src/cli/helpers/issue-tracker/index.js +26 -9
  13. package/dist/src/cli/helpers/issue-tracker/index.js.map +1 -1
  14. package/dist/src/cli/helpers/issue-tracker/types.d.ts +1 -0
  15. package/dist/src/cli/helpers/issue-tracker/types.d.ts.map +1 -1
  16. package/dist/src/cli/helpers/issue-tracker/types.js.map +1 -1
  17. package/dist/src/core/repo-structure/git-error-handler.d.ts +37 -0
  18. package/dist/src/core/repo-structure/git-error-handler.d.ts.map +1 -0
  19. package/dist/src/core/repo-structure/git-error-handler.js +214 -0
  20. package/dist/src/core/repo-structure/git-error-handler.js.map +1 -0
  21. package/dist/src/core/repo-structure/git-provider.d.ts +183 -0
  22. package/dist/src/core/repo-structure/git-provider.d.ts.map +1 -0
  23. package/dist/src/core/repo-structure/git-provider.js +57 -0
  24. package/dist/src/core/repo-structure/git-provider.js.map +1 -0
  25. package/dist/src/core/repo-structure/github-validator.d.ts +1 -0
  26. package/dist/src/core/repo-structure/github-validator.d.ts.map +1 -1
  27. package/dist/src/core/repo-structure/github-validator.js +35 -9
  28. package/dist/src/core/repo-structure/github-validator.js.map +1 -1
  29. package/dist/src/core/repo-structure/platform-registry.d.ts +114 -0
  30. package/dist/src/core/repo-structure/platform-registry.d.ts.map +1 -0
  31. package/dist/src/core/repo-structure/platform-registry.js +195 -0
  32. package/dist/src/core/repo-structure/platform-registry.js.map +1 -0
  33. package/dist/src/core/repo-structure/prompt-consolidator.d.ts +30 -0
  34. package/dist/src/core/repo-structure/prompt-consolidator.d.ts.map +1 -1
  35. package/dist/src/core/repo-structure/prompt-consolidator.js +69 -0
  36. package/dist/src/core/repo-structure/prompt-consolidator.js.map +1 -1
  37. package/dist/src/core/repo-structure/providers/bitbucket-provider.d.ts +54 -0
  38. package/dist/src/core/repo-structure/providers/bitbucket-provider.d.ts.map +1 -0
  39. package/dist/src/core/repo-structure/providers/bitbucket-provider.js +104 -0
  40. package/dist/src/core/repo-structure/providers/bitbucket-provider.js.map +1 -0
  41. package/dist/src/core/repo-structure/providers/github-provider.d.ts +53 -0
  42. package/dist/src/core/repo-structure/providers/github-provider.d.ts.map +1 -0
  43. package/dist/src/core/repo-structure/providers/github-provider.js +239 -0
  44. package/dist/src/core/repo-structure/providers/github-provider.js.map +1 -0
  45. package/dist/src/core/repo-structure/providers/gitlab-provider.d.ts +50 -0
  46. package/dist/src/core/repo-structure/providers/gitlab-provider.d.ts.map +1 -0
  47. package/dist/src/core/repo-structure/providers/gitlab-provider.js +97 -0
  48. package/dist/src/core/repo-structure/providers/gitlab-provider.js.map +1 -0
  49. package/dist/src/core/repo-structure/providers/index.d.ts +33 -0
  50. package/dist/src/core/repo-structure/providers/index.d.ts.map +1 -0
  51. package/dist/src/core/repo-structure/providers/index.js +60 -0
  52. package/dist/src/core/repo-structure/providers/index.js.map +1 -0
  53. package/dist/src/core/repo-structure/repo-structure-manager.d.ts +10 -3
  54. package/dist/src/core/repo-structure/repo-structure-manager.d.ts.map +1 -1
  55. package/dist/src/core/repo-structure/repo-structure-manager.js +125 -42
  56. package/dist/src/core/repo-structure/repo-structure-manager.js.map +1 -1
  57. package/dist/src/core/repo-structure/url-generator.d.ts +80 -0
  58. package/dist/src/core/repo-structure/url-generator.d.ts.map +1 -0
  59. package/dist/src/core/repo-structure/url-generator.js +110 -0
  60. package/dist/src/core/repo-structure/url-generator.js.map +1 -0
  61. package/package.json +1 -1
  62. package/plugins/specweave-ado/lib/ado-multi-project-sync.js +0 -1
  63. package/plugins/specweave-jira/lib/enhanced-jira-sync.js +3 -3
  64. package/plugins/specweave/agents/pm/AGENT.md.bak +0 -1893
  65. package/plugins/specweave/hooks/docs-changed.sh.backup +0 -79
  66. package/plugins/specweave/hooks/human-input-required.sh.backup +0 -75
  67. package/plugins/specweave/hooks/lib/migrate-increment-work.sh.bak +0 -245
  68. package/plugins/specweave/hooks/lib/sync-spec-content.sh.bak +0 -149
  69. package/plugins/specweave/hooks/lib/validate-spec-status.sh.bak +0 -163
  70. package/plugins/specweave/hooks/post-first-increment.sh.backup +0 -61
  71. package/plugins/specweave/hooks/post-first-increment.sh.bak +0 -61
  72. package/plugins/specweave/hooks/post-increment-change.sh.backup +0 -98
  73. package/plugins/specweave/hooks/post-increment-completion.sh.backup +0 -231
  74. package/plugins/specweave/hooks/post-increment-planning.sh.backup +0 -1048
  75. package/plugins/specweave/hooks/post-increment-status-change.sh.backup +0 -147
  76. package/plugins/specweave/hooks/post-spec-update.sh.backup +0 -158
  77. package/plugins/specweave/hooks/post-spec-update.sh.bak +0 -158
  78. package/plugins/specweave/hooks/post-user-story-complete.sh.backup +0 -179
  79. package/plugins/specweave/hooks/post-user-story-complete.sh.bak +0 -179
  80. package/plugins/specweave/hooks/pre-command-deduplication.sh.backup +0 -83
  81. package/plugins/specweave/hooks/pre-command-deduplication.sh.bak +0 -83
  82. package/plugins/specweave/hooks/pre-implementation.sh.backup +0 -67
  83. package/plugins/specweave/hooks/pre-task-completion.sh.backup +0 -194
  84. package/plugins/specweave/hooks/pre-tool-use.sh.backup +0 -133
  85. package/plugins/specweave/hooks/user-prompt-submit.sh.backup +0 -386
  86. package/plugins/specweave/hooks/user-prompt-submit.sh.bak +0 -386
  87. package/plugins/specweave/lib/hooks/auto-transition.js.bak +0 -50
  88. package/plugins/specweave/lib/hooks/auto-transition.ts.bak +0 -84
  89. package/plugins/specweave/lib/hooks/git-diff-analyzer.d.js.bak +0 -0
  90. package/plugins/specweave/lib/hooks/git-diff-analyzer.d.ts.bak +0 -89
  91. package/plugins/specweave/lib/hooks/git-diff-analyzer.js.bak +0 -142
  92. package/plugins/specweave/lib/hooks/git-diff-analyzer.ts.bak +0 -269
  93. package/plugins/specweave/lib/hooks/invoke-translator-skill.d.js.bak +0 -0
  94. package/plugins/specweave/lib/hooks/invoke-translator-skill.d.ts.bak +0 -60
  95. package/plugins/specweave/lib/hooks/invoke-translator-skill.js.bak +0 -155
  96. package/plugins/specweave/lib/hooks/invoke-translator-skill.ts.bak +0 -264
  97. package/plugins/specweave/lib/hooks/prepare-reflection-context.d.js.bak +0 -0
  98. package/plugins/specweave/lib/hooks/prepare-reflection-context.d.ts.bak +0 -42
  99. package/plugins/specweave/lib/hooks/prepare-reflection-context.js.bak +0 -110
  100. package/plugins/specweave/lib/hooks/prepare-reflection-context.ts.bak +0 -178
  101. package/plugins/specweave/lib/hooks/reflection-config-loader.d.js.bak +0 -0
  102. package/plugins/specweave/lib/hooks/reflection-config-loader.d.ts.bak +0 -45
  103. package/plugins/specweave/lib/hooks/reflection-config-loader.js.bak +0 -92
  104. package/plugins/specweave/lib/hooks/reflection-config-loader.ts.bak +0 -156
  105. package/plugins/specweave/lib/hooks/reflection-parser.d.js.bak +0 -0
  106. package/plugins/specweave/lib/hooks/reflection-parser.d.ts.bak +0 -33
  107. package/plugins/specweave/lib/hooks/reflection-parser.js.bak +0 -301
  108. package/plugins/specweave/lib/hooks/reflection-parser.ts.bak +0 -484
  109. package/plugins/specweave/lib/hooks/reflection-prompt-builder.d.js.bak +0 -0
  110. package/plugins/specweave/lib/hooks/reflection-prompt-builder.d.ts.bak +0 -56
  111. package/plugins/specweave/lib/hooks/reflection-prompt-builder.js.bak +0 -182
  112. package/plugins/specweave/lib/hooks/reflection-prompt-builder.ts.bak +0 -306
  113. package/plugins/specweave/lib/hooks/reflection-storage.d.js.bak +0 -0
  114. package/plugins/specweave/lib/hooks/reflection-storage.d.ts.bak +0 -64
  115. package/plugins/specweave/lib/hooks/reflection-storage.js.bak +0 -231
  116. package/plugins/specweave/lib/hooks/reflection-storage.ts.bak +0 -369
  117. package/plugins/specweave/lib/hooks/run-self-reflection.d.js.bak +0 -0
  118. package/plugins/specweave/lib/hooks/run-self-reflection.d.ts.bak +0 -43
  119. package/plugins/specweave/lib/hooks/run-self-reflection.js.bak +0 -132
  120. package/plugins/specweave/lib/hooks/run-self-reflection.ts.bak +0 -258
  121. package/plugins/specweave/lib/hooks/sync-cache.js.bak +0 -294
  122. package/plugins/specweave/lib/hooks/sync-living-docs.d.js.bak +0 -1
  123. package/plugins/specweave/lib/hooks/sync-living-docs.d.ts.bak +0 -27
  124. package/plugins/specweave/lib/hooks/sync-living-docs.js.bak +0 -339
  125. package/plugins/specweave/lib/hooks/sync-us-tasks.js.bak +0 -476
  126. package/plugins/specweave/lib/hooks/translate-file.d.js.bak +0 -0
  127. package/plugins/specweave/lib/hooks/translate-file.d.ts.bak +0 -59
  128. package/plugins/specweave/lib/hooks/translate-file.js.bak +0 -289
  129. package/plugins/specweave/lib/hooks/translate-file.ts.bak +0 -428
  130. package/plugins/specweave/lib/hooks/translate-living-docs.d.js.bak +0 -0
  131. package/plugins/specweave/lib/hooks/translate-living-docs.d.ts.bak +0 -13
  132. package/plugins/specweave/lib/hooks/translate-living-docs.js.bak +0 -119
  133. package/plugins/specweave/lib/hooks/translate-living-docs.ts.bak +0 -224
  134. package/plugins/specweave/lib/hooks/update-ac-status.js.bak +0 -51
  135. package/plugins/specweave/lib/hooks/update-ac-status.ts.bak +0 -103
  136. package/plugins/specweave/lib/hooks/update-tasks-md.d.js.bak +0 -1
  137. package/plugins/specweave/lib/hooks/update-tasks-md.d.ts.bak +0 -29
  138. package/plugins/specweave/lib/hooks/update-tasks-md.js.bak +0 -296
  139. package/plugins/specweave/lib/hooks/update-tasks-md.ts.bak +0 -489
  140. package/plugins/specweave-ado/hooks/post-living-docs-update.sh.backup +0 -353
  141. package/plugins/specweave-ado/hooks/post-task-completion.sh.backup +0 -172
  142. package/plugins/specweave-ado/lib/enhanced-ado-sync.js +0 -170
  143. package/plugins/specweave-github/hooks/.specweave/logs/hooks-debug.log +0 -360
  144. package/plugins/specweave-github/hooks/post-task-completion.sh.backup +0 -258
  145. package/plugins/specweave-jira/hooks/post-task-completion.sh.backup +0 -172
  146. package/plugins/specweave-release/hooks/.specweave/logs/dora-tracking.log +0 -444
  147. package/plugins/specweave-release/hooks/post-task-completion.sh.backup +0 -110
@@ -1,179 +0,0 @@
1
- #!/bin/bash
2
-
3
- ###############################################################################
4
- # SpecWeave Post-User-Story-Complete Hook
5
- #
6
- # CRITICAL ARCHITECTURE:
7
- # - Fires when user story marked complete in spec.md (AC checkbox checked)
8
- # - Updates external PM tool (GitHub Issue/Jira Story/ADO User Story)
9
- # - Moves GitHub card to "Done" / Closes Jira story / Completes ADO story
10
- #
11
- # Trigger Points:
12
- # 1. After user manually checks AC checkbox in spec.md
13
- # 2. After bidirectional sync updates AC status
14
- # 3. After increment completion syncs to spec
15
- #
16
- # What It Does:
17
- # - Detects which user story was completed (all AC checkboxes checked)
18
- # - Finds corresponding external item (GitHub Issue/Jira Story/ADO User Story)
19
- # - Updates item status to "Done" / "Closed"
20
- # - Adds completion comment with timestamp
21
- #
22
- # Usage:
23
- # post-user-story-complete.sh <spec-id> <user-story-id>
24
- #
25
- # Example:
26
- # post-user-story-complete.sh spec-001 US-001
27
- #
28
- ###############################################################################
29
-
30
- set -euo pipefail
31
-
32
- # Arguments
33
- SPEC_ID="${1:-}"
34
- USER_STORY_ID="${2:-}"
35
-
36
- # Validate arguments
37
- if [[ -z "$SPEC_ID" || -z "$USER_STORY_ID" ]]; then
38
- echo "❌ Error: Spec ID and User Story ID required"
39
- echo "Usage: post-user-story-complete.sh <spec-id> <user-story-id>"
40
- exit 1
41
- fi
42
-
43
- echo ""
44
- echo "🎉 Post-User-Story-Complete Hook"
45
- echo " Spec: $SPEC_ID"
46
- echo " User Story: $USER_STORY_ID"
47
-
48
- # Find spec file
49
- SPEC_FILE=""
50
- if [[ -f ".specweave/docs/internal/specs/$SPEC_ID.md" ]]; then
51
- SPEC_FILE=".specweave/docs/internal/specs/$SPEC_ID.md"
52
- elif [[ -f ".specweave/docs/internal/projects/default/specs/$SPEC_ID.md" ]]; then
53
- SPEC_FILE=".specweave/docs/internal/projects/default/specs/$SPEC_ID.md"
54
- else
55
- echo "❌ Error: Spec file not found for $SPEC_ID"
56
- exit 1
57
- fi
58
-
59
- # Load config to check if auto-sync is enabled
60
- CONFIG_FILE=".specweave/config.json"
61
- if [[ ! -f "$CONFIG_FILE" ]]; then
62
- echo " â„šī¸ No config file found, skipping auto-sync"
63
- exit 0
64
- fi
65
-
66
- # Check if auto-sync is enabled
67
- AUTO_SYNC=$(jq -r '.hooks.post_user_story_complete.auto_sync // true' "$CONFIG_FILE")
68
-
69
- if [[ "$AUTO_SYNC" != "true" ]]; then
70
- echo " â„šī¸ Auto-sync disabled in config, skipping"
71
- exit 0
72
- fi
73
-
74
- # Parse spec frontmatter to detect external links
75
- # Check if GitHub link exists
76
- GITHUB_LINK=$(grep -A 10 "^externalLinks:" "$SPEC_FILE" | grep -A 5 "github:" | grep "projectId:" | sed 's/.*projectId: *//; s/ *$//' || echo "")
77
-
78
- # Check if Jira link exists
79
- JIRA_LINK=$(grep -A 10 "^externalLinks:" "$SPEC_FILE" | grep -A 5 "jira:" | grep "epicKey:" | sed 's/.*epicKey: *//; s/ *$//' || echo "")
80
-
81
- # Check if ADO link exists
82
- ADO_LINK=$(grep -A 10 "^externalLinks:" "$SPEC_FILE" | grep -A 5 "ado:" | grep "featureId:" | sed 's/.*featureId: *//; s/ *$//' || echo "")
83
-
84
- # Determine which provider to sync
85
- PROVIDER=""
86
- if [[ -n "$GITHUB_LINK" ]]; then
87
- PROVIDER="github"
88
- EXTERNAL_ID="$GITHUB_LINK"
89
- elif [[ -n "$JIRA_LINK" ]]; then
90
- PROVIDER="jira"
91
- EXTERNAL_ID="$JIRA_LINK"
92
- elif [[ -n "$ADO_LINK" ]]; then
93
- PROVIDER="ado"
94
- EXTERNAL_ID="$ADO_LINK"
95
- fi
96
-
97
- # No external link found - skip sync
98
- if [[ -z "$PROVIDER" ]]; then
99
- echo " â„šī¸ Spec not linked to external tool, skipping sync"
100
- exit 0
101
- fi
102
-
103
- echo " 🔗 Detected external link: $PROVIDER"
104
-
105
- # Update external tool based on provider
106
- case "$PROVIDER" in
107
- github)
108
- echo " 🔄 Updating GitHub Issue for $USER_STORY_ID..."
109
-
110
- # Check if GitHub CLI is available
111
- if ! command -v gh &> /dev/null; then
112
- echo " âš ī¸ GitHub CLI (gh) not found, skipping sync"
113
- exit 0
114
- fi
115
-
116
- # Find GitHub Issue for this user story
117
- # Search for issue with title pattern "[USER_STORY_ID]"
118
- REPO=$(git remote get-url origin | sed -E 's/.*github\.com[:/]([^/]+\/[^/]+)(\.git)?$/\1/')
119
-
120
- # Search for issue
121
- ISSUE_NUMBER=$(gh issue list --repo "$REPO" --search "\"[$USER_STORY_ID]\" in:title" --json number --jq '.[0].number' 2>/dev/null || echo "")
122
-
123
- if [[ -z "$ISSUE_NUMBER" ]]; then
124
- echo " âš ī¸ GitHub Issue not found for $USER_STORY_ID"
125
- exit 0
126
- fi
127
-
128
- echo " 📝 Found GitHub Issue #$ISSUE_NUMBER"
129
-
130
- # Close issue
131
- gh issue close "$ISSUE_NUMBER" --repo "$REPO" --comment "✅ User story completed
132
-
133
- 🤖 Auto-closed by SpecWeave hook
134
- Completed at: $(date -u +%Y-%m-%dT%H:%M:%SZ)" 2>/dev/null || {
135
- echo " âš ī¸ Failed to close issue"
136
- exit 0
137
- }
138
-
139
- echo " ✅ GitHub Issue #$ISSUE_NUMBER closed"
140
- ;;
141
-
142
- jira)
143
- echo " 🔄 Updating Jira Story for $USER_STORY_ID..."
144
-
145
- # Check if Jira config exists
146
- if [[ -z "${JIRA_DOMAIN:-}" ]]; then
147
- echo " âš ī¸ Jira not configured (.env), skipping sync"
148
- exit 0
149
- fi
150
-
151
- # TODO: Find Jira Story by title pattern
152
- # TODO: Transition story to "Done" status
153
- echo " ✅ Jira story transition queued (implementation pending)"
154
- ;;
155
-
156
- ado)
157
- echo " 🔄 Updating ADO User Story for $USER_STORY_ID..."
158
-
159
- # Check if ADO config exists
160
- if [[ -z "${ADO_ORGANIZATION:-}" ]]; then
161
- echo " âš ī¸ ADO not configured (.env), skipping sync"
162
- exit 0
163
- fi
164
-
165
- # TODO: Find ADO User Story by title pattern
166
- # TODO: Update state to "Closed"
167
- echo " ✅ ADO user story update queued (implementation pending)"
168
- ;;
169
-
170
- *)
171
- echo " âš ī¸ Unknown provider: $PROVIDER"
172
- exit 0
173
- ;;
174
- esac
175
-
176
- echo " ✅ Post-user-story-complete hook complete"
177
- echo ""
178
-
179
- exit 0
@@ -1,83 +0,0 @@
1
- #!/bin/bash
2
-
3
- # SpecWeave Pre-Command Deduplication Hook
4
- # Fires BEFORE any command executes (UserPromptSubmit hook)
5
- # Purpose: Prevent duplicate command invocations within configurable time window
6
-
7
- set -euo pipefail
8
-
9
- # ==============================================================================
10
- # PROJECT ROOT DETECTION
11
- # ==============================================================================
12
-
13
- # Find project root by searching upward for .specweave/ directory
14
- find_project_root() {
15
- local dir="$1"
16
- while [ "$dir" != "/" ]; do
17
- if [ -d "$dir/.specweave" ]; then
18
- echo "$dir"
19
- return 0
20
- fi
21
- dir="$(dirname "$dir")"
22
- done
23
- # Fallback: try current directory
24
- if [ -d "$(pwd)/.specweave" ]; then
25
- pwd
26
- else
27
- echo "$(pwd)"
28
- fi
29
- }
30
-
31
- PROJECT_ROOT="$(find_project_root "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")"
32
- cd "$PROJECT_ROOT" 2>/dev/null || true
33
-
34
- # Read input JSON from stdin
35
- INPUT=$(cat)
36
-
37
- # ==============================================================================
38
- # DEDUPLICATION CHECK: Block duplicate commands within 1 second
39
- # ==============================================================================
40
-
41
- # Check if deduplication module is available
42
- if command -v node >/dev/null 2>&1 && [[ -f "dist/src/core/deduplication/command-deduplicator.js" ]]; then
43
- # Use dedicated wrapper script for ES module compatibility
44
- DEDUP_RESULT=$(echo "$INPUT" | node scripts/check-deduplication.js 2>/dev/null || echo "OK")
45
-
46
- # Parse result
47
- STATUS=$(echo "$DEDUP_RESULT" | head -1)
48
-
49
- if [[ "$STATUS" == "DUPLICATE" ]]; then
50
- # Get stats
51
- STATS=$(echo "$DEDUP_RESULT" | tail -1)
52
-
53
- # Extract command and stats for readable message
54
- COMMAND=$(echo "$STATS" | grep -o '"lastCommand":"[^"]*"' | cut -d'"' -f4 || echo "unknown")
55
- TOTAL_BLOCKED=$(echo "$STATS" | grep -o '"totalDuplicatesBlocked":[0-9]*' | cut -d':' -f2 || echo "1")
56
- CACHE_SIZE=$(echo "$STATS" | grep -o '"currentCacheSize":[0-9]*' | cut -d':' -f2 || echo "1")
57
-
58
- # Build error message WITHOUT embedding JSON (avoid escaping issues)
59
- MESSAGE=$(cat <<'EOF'
60
- {
61
- "decision": "block",
62
- "reason": "đŸšĢ DUPLICATE COMMAND DETECTED\n\nCommand: `COMMAND_PLACEHOLDER`\nTime window: 1 second\n\nThis command was just executed! To prevent unintended duplicates, this invocation has been blocked.\n\n💡 If you meant to run this command again:\n 1. Wait 1 second\n 2. Run the command again\n\nDeduplication Stats:\n- Total duplicates blocked: BLOCKED_PLACEHOLDER\n- Commands in cache: CACHE_PLACEHOLDER"
63
- }
64
- EOF
65
- )
66
- # Replace placeholders (avoids JSON escaping issues)
67
- # Use | as sed delimiter to avoid conflicts with / in command names
68
- echo "$MESSAGE" | sed "s|COMMAND_PLACEHOLDER|$COMMAND|g" | sed "s|BLOCKED_PLACEHOLDER|$TOTAL_BLOCKED|g" | sed "s|CACHE_PLACEHOLDER|$CACHE_SIZE|g"
69
- exit 0
70
- fi
71
- fi
72
-
73
- # ==============================================================================
74
- # PASS THROUGH: No duplicate detected, proceed with command
75
- # ==============================================================================
76
-
77
- cat <<EOF
78
- {
79
- "decision": "approve"
80
- }
81
- EOF
82
-
83
- exit 0
@@ -1,83 +0,0 @@
1
- #!/bin/bash
2
-
3
- # SpecWeave Pre-Command Deduplication Hook
4
- # Fires BEFORE any command executes (UserPromptSubmit hook)
5
- # Purpose: Prevent duplicate command invocations within configurable time window
6
-
7
- set -euo pipefail
8
-
9
- # ==============================================================================
10
- # PROJECT ROOT DETECTION
11
- # ==============================================================================
12
-
13
- # Find project root by searching upward for .specweave/ directory
14
- find_project_root() {
15
- local dir="$1"
16
- while [ "$dir" != "/" ]; do
17
- if [ -d "$dir/.specweave" ]; then
18
- echo "$dir"
19
- return 0
20
- fi
21
- dir="$(dirname "$dir")"
22
- done
23
- # Fallback: try current directory
24
- if [ -d "$(pwd)/.specweave" ]; then
25
- pwd
26
- else
27
- echo "$(pwd)"
28
- fi
29
- }
30
-
31
- PROJECT_ROOT="$(find_project_root "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")"
32
- cd "$PROJECT_ROOT" 2>/dev/null || true
33
-
34
- # Read input JSON from stdin
35
- INPUT=$(cat)
36
-
37
- # ==============================================================================
38
- # DEDUPLICATION CHECK: Block duplicate commands within 1 second
39
- # ==============================================================================
40
-
41
- # Check if deduplication module is available
42
- if command -v node >/dev/null 2>&1 && [[ -f "dist/src/core/deduplication/command-deduplicator.js" ]]; then
43
- # Use dedicated wrapper script for ES module compatibility
44
- DEDUP_RESULT=$(echo "$INPUT" | node scripts/check-deduplication.js 2>/dev/null || echo "OK")
45
-
46
- # Parse result
47
- STATUS=$(echo "$DEDUP_RESULT" | head -1)
48
-
49
- if [[ "$STATUS" == "DUPLICATE" ]]; then
50
- # Get stats
51
- STATS=$(echo "$DEDUP_RESULT" | tail -1)
52
-
53
- # Extract command and stats for readable message
54
- COMMAND=$(echo "$STATS" | grep -o '"lastCommand":"[^"]*"' | cut -d'"' -f4 || echo "unknown")
55
- TOTAL_BLOCKED=$(echo "$STATS" | grep -o '"totalDuplicatesBlocked":[0-9]*' | cut -d':' -f2 || echo "1")
56
- CACHE_SIZE=$(echo "$STATS" | grep -o '"currentCacheSize":[0-9]*' | cut -d':' -f2 || echo "1")
57
-
58
- # Build error message WITHOUT embedding JSON (avoid escaping issues)
59
- MESSAGE=$(cat <<'EOF'
60
- {
61
- "decision": "block",
62
- "reason": "đŸšĢ DUPLICATE COMMAND DETECTED\n\nCommand: `COMMAND_PLACEHOLDER`\nTime window: 1 second\n\nThis command was just executed! To prevent unintended duplicates, this invocation has been blocked.\n\n💡 If you meant to run this command again:\n 1. Wait 1 second\n 2. Run the command again\n\nDeduplication Stats:\n- Total duplicates blocked: BLOCKED_PLACEHOLDER\n- Commands in cache: CACHE_PLACEHOLDER"
63
- }
64
- EOF
65
- )
66
- # Replace placeholders (avoids JSON escaping issues)
67
- # Use | as sed delimiter to avoid conflicts with / in command names
68
- echo "$MESSAGE" | sed "s|COMMAND_PLACEHOLDER|$COMMAND|g" | sed "s|BLOCKED_PLACEHOLDER|$TOTAL_BLOCKED|g" | sed "s|CACHE_PLACEHOLDER|$CACHE_SIZE|g"
69
- exit 0
70
- fi
71
- fi
72
-
73
- # ==============================================================================
74
- # PASS THROUGH: No duplicate detected, proceed with command
75
- # ==============================================================================
76
-
77
- cat <<EOF
78
- {
79
- "decision": "approve"
80
- }
81
- EOF
82
-
83
- exit 0
@@ -1,67 +0,0 @@
1
- #!/bin/bash
2
-
3
- # SpecWeave Pre-Implementation Hook
4
- # Runs before starting implementation of a task
5
- # Checks regression risk for brownfield projects
6
-
7
- set -e
8
-
9
- # Find project root by searching upward for .specweave/ directory
10
- # Works regardless of where hook is installed (source or .claude/hooks/)
11
- find_project_root() {
12
- local dir="$1"
13
- while [ "$dir" != "/" ]; do
14
- if [ -d "$dir/.specweave" ]; then
15
- echo "$dir"
16
- return 0
17
- fi
18
- dir="$(dirname "$dir")"
19
- done
20
- # Fallback: try current directory
21
- if [ -d "$(pwd)/.specweave" ]; then
22
- pwd
23
- else
24
- echo "$(pwd)"
25
- fi
26
- }
27
-
28
- PROJECT_ROOT="$(find_project_root "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")"
29
- cd "$PROJECT_ROOT"
30
-
31
- # Colors
32
- YELLOW='\033[1;33m'
33
- BLUE='\033[0;34m'
34
- GREEN='\033[0;32m'
35
- NC='\033[0m'
36
-
37
- echo -e "${BLUE}🔍 Pre-Implementation Check${NC}"
38
-
39
- # Check if this is a brownfield project (has existing code)
40
- if [ -d "src" ] || [ -d "app" ] || [ -d "lib" ]; then
41
- echo -e "${YELLOW}âš ī¸ Brownfield project detected${NC}"
42
- echo ""
43
- echo "Recommendations:"
44
- echo " 1. Create baseline tests before changes"
45
- echo " 2. Check for existing tests that may break"
46
- echo " 3. Review impact on existing features"
47
- echo ""
48
-
49
- # Check if baseline tests exist
50
- if [ -d ".specweave/tests/baseline" ]; then
51
- echo -e "${GREEN}✅ Baseline tests exist${NC}"
52
- else
53
- echo -e "${YELLOW}âš ī¸ No baseline tests found${NC}"
54
- echo " Consider creating baseline tests first"
55
- echo " This captures current state before changes"
56
- fi
57
- else
58
- echo -e "${GREEN}✅ Greenfield project - no regression risk${NC}"
59
- fi
60
-
61
- # Log to hooks log
62
- LOGS_DIR=".specweave/logs"
63
- mkdir -p "$LOGS_DIR"
64
- echo "[$(date)] Pre-implementation check complete" >> "$LOGS_DIR/hooks.log"
65
-
66
- echo ""
67
- echo -e "${GREEN}✅ Pre-implementation check complete${NC}"
@@ -1,194 +0,0 @@
1
- #!/bin/bash
2
-
3
- # SpecWeave Pre-Task-Completion Hook
4
- # CRITICAL QUALITY GATE: Validates AC tests before allowing task completion
5
- #
6
- # Runs automatically BEFORE any task is marked complete via TodoWrite
7
- #
8
- # WORKFLOW:
9
- # =========
10
- # 1. TodoWrite called with status="completed"
11
- # 2. This hook fires (pre-completion validation)
12
- # 3. Extract task ID from TodoWrite input
13
- # 4. Find task in tasks.md
14
- # 5. Run AC test validator
15
- # 6. If tests PASS → Allow completion (continue: true)
16
- # 7. If tests FAIL → Block completion (continue: false, show error)
17
- #
18
- # ENFORCEMENT:
19
- # ============
20
- # This is the ONLY way to mark tasks complete in SpecWeave.
21
- # Manual edits to tasks.md are detected and flagged by pre-commit hooks.
22
-
23
- set -e
24
-
25
- # Find project root
26
- find_project_root() {
27
- local dir="$1"
28
- while [ "$dir" != "/" ]; do
29
- if [ -d "$dir/.specweave" ]; then
30
- echo "$dir"
31
- return 0
32
- fi
33
- dir="$(dirname "$dir")"
34
- done
35
- pwd
36
- }
37
-
38
- PROJECT_ROOT="$(find_project_root "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")"
39
- cd "$PROJECT_ROOT" 2>/dev/null || true
40
-
41
- # ============================================================================
42
- # CONFIGURATION
43
- # ============================================================================
44
-
45
- LOGS_DIR=".specweave/logs"
46
- DEBUG_LOG="$LOGS_DIR/hooks-debug.log"
47
-
48
- mkdir -p "$LOGS_DIR" 2>/dev/null || true
49
-
50
- echo "[$(date)] 🔒 Pre-task-completion hook fired" >> "$DEBUG_LOG" 2>/dev/null || true
51
-
52
- # ============================================================================
53
- # CAPTURE INPUT
54
- # ============================================================================
55
-
56
- STDIN_DATA=$(mktemp)
57
- cat > "$STDIN_DATA"
58
-
59
- echo "[$(date)] Input JSON:" >> "$DEBUG_LOG" 2>/dev/null || true
60
- cat "$STDIN_DATA" >> "$DEBUG_LOG" 2>/dev/null || true
61
-
62
- # ============================================================================
63
- # CHECK FOR TASK COMPLETION
64
- # ============================================================================
65
-
66
- # Only validate if a task is being marked complete
67
- COMPLETING_TASK=false
68
-
69
- if command -v jq >/dev/null 2>&1; then
70
- # Check if any task is transitioning to "completed" status
71
- COMPLETED_COUNT=$(jq -r '.tool_input.todos // [] | map(select(.status == "completed")) | length' "$STDIN_DATA" 2>/dev/null || echo "0")
72
-
73
- if [ "$COMPLETED_COUNT" != "0" ]; then
74
- COMPLETING_TASK=true
75
- echo "[$(date)] ✓ Detected task completion (${COMPLETED_COUNT} tasks)" >> "$DEBUG_LOG" 2>/dev/null || true
76
- fi
77
- fi
78
-
79
- # If no tasks being completed, allow without validation
80
- if [ "$COMPLETING_TASK" = "false" ]; then
81
- echo "[$(date)] â­ī¸ No tasks being completed, skipping validation" >> "$DEBUG_LOG" 2>/dev/null || true
82
- rm -f "$STDIN_DATA"
83
- cat <<EOF
84
- {
85
- "continue": true
86
- }
87
- EOF
88
- exit 0
89
- fi
90
-
91
- # ============================================================================
92
- # DETECT CURRENT INCREMENT
93
- # ============================================================================
94
-
95
- CURRENT_INCREMENT=$(ls -td .specweave/increments/*/ 2>/dev/null | xargs -n1 basename | grep -v "_backlog" | grep -v "_archive" | grep -v "_working" | head -1)
96
-
97
- if [ -z "$CURRENT_INCREMENT" ]; then
98
- echo "[$(date)] â„šī¸ No active increment found, skipping validation" >> "$DEBUG_LOG" 2>/dev/null || true
99
- rm -f "$STDIN_DATA"
100
- cat <<EOF
101
- {
102
- "continue": true
103
- }
104
- EOF
105
- exit 0
106
- fi
107
-
108
- TASKS_MD=".specweave/increments/$CURRENT_INCREMENT/tasks.md"
109
-
110
- if [ ! -f "$TASKS_MD" ]; then
111
- echo "[$(date)] â„šī¸ tasks.md not found for $CURRENT_INCREMENT (increment may be in planning stage)" >> "$DEBUG_LOG" 2>/dev/null || true
112
- rm -f "$STDIN_DATA"
113
- cat <<EOF
114
- {
115
- "continue": true
116
- }
117
- EOF
118
- exit 0
119
- fi
120
-
121
- # ============================================================================
122
- # RUN AC TEST VALIDATION
123
- # ============================================================================
124
-
125
- echo "[$(date)] đŸ§Ē Running AC test validation for $CURRENT_INCREMENT" >> "$DEBUG_LOG" 2>/dev/null || true
126
-
127
- # Determine which validation script to use
128
- VALIDATOR_SCRIPT=""
129
- if [ -f "$PROJECT_ROOT/dist/src/core/ac-test-validator-cli.js" ]; then
130
- VALIDATOR_SCRIPT="$PROJECT_ROOT/dist/src/core/ac-test-validator-cli.js"
131
- elif [ -f "$PROJECT_ROOT/node_modules/specweave/dist/src/core/ac-test-validator-cli.js" ]; then
132
- VALIDATOR_SCRIPT="$PROJECT_ROOT/node_modules/specweave/dist/src/core/ac-test-validator-cli.js"
133
- elif [ -n "${CLAUDE_PLUGIN_ROOT}" ] && [ -f "${CLAUDE_PLUGIN_ROOT}/dist/src/core/ac-test-validator-cli.js" ]; then
134
- VALIDATOR_SCRIPT="${CLAUDE_PLUGIN_ROOT}/dist/src/core/ac-test-validator-cli.js"
135
- fi
136
-
137
- if [ -z "$VALIDATOR_SCRIPT" ] || ! command -v node &> /dev/null; then
138
- echo "[$(date)] âš ī¸ AC test validator not found or Node.js missing" >> "$DEBUG_LOG" 2>/dev/null || true
139
- rm -f "$STDIN_DATA"
140
- cat <<EOF
141
- {
142
- "continue": true,
143
- "systemMessage": "âš ī¸ Warning: AC test validator not available. Task completion validation skipped. Install Node.js and rebuild SpecWeave to enable validation."
144
- }
145
- EOF
146
- exit 0
147
- fi
148
-
149
- # Run validator (captures exit code)
150
- VALIDATION_OUTPUT=$(mktemp)
151
- VALIDATION_EXIT_CODE=0
152
-
153
- (cd "$PROJECT_ROOT" && node "$VALIDATOR_SCRIPT" "$CURRENT_INCREMENT") > "$VALIDATION_OUTPUT" 2>&1 || VALIDATION_EXIT_CODE=$?
154
-
155
- echo "[$(date)] Validator exit code: $VALIDATION_EXIT_CODE" >> "$DEBUG_LOG" 2>/dev/null || true
156
- cat "$VALIDATION_OUTPUT" >> "$DEBUG_LOG" 2>/dev/null || true
157
-
158
- rm -f "$STDIN_DATA"
159
-
160
- # ============================================================================
161
- # DECISION LOGIC
162
- # ============================================================================
163
-
164
- if [ "$VALIDATION_EXIT_CODE" = "0" ]; then
165
- # Validation passed - allow completion
166
- echo "[$(date)] ✅ AC test validation passed" >> "$DEBUG_LOG" 2>/dev/null || true
167
-
168
- VALIDATION_SUMMARY=$(cat "$VALIDATION_OUTPUT" | tail -5 | tr '\n' ' ')
169
-
170
- rm -f "$VALIDATION_OUTPUT"
171
-
172
- cat <<EOF
173
- {
174
- "continue": true,
175
- "systemMessage": "✅ AC Test Validation Passed: All acceptance criteria have passing tests. Task completion allowed. ${VALIDATION_SUMMARY}"
176
- }
177
- EOF
178
- else
179
- # Validation failed - block completion
180
- echo "[$(date)] ❌ AC test validation failed" >> "$DEBUG_LOG" 2>/dev/null || true
181
-
182
- VALIDATION_ERROR=$(cat "$VALIDATION_OUTPUT" | grep -A 10 "VALIDATION FAILED" | tr '\n' ' ' | cut -c 1-300)
183
-
184
- rm -f "$VALIDATION_OUTPUT"
185
-
186
- cat <<EOF
187
- {
188
- "continue": false,
189
- "systemMessage": "❌ AC TEST VALIDATION FAILED: Cannot mark task as complete until all acceptance criteria have passing tests. ${VALIDATION_ERROR}
190
-
191
- Fix the failing tests and try again. Run tests manually: npm test"
192
- }
193
- EOF
194
- fi