specweave 1.0.550 → 1.0.552

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 (166) hide show
  1. package/CLAUDE.md +1 -1
  2. package/bin/specweave.js +23 -1
  3. package/dist/src/cli/commands/hook.d.ts +15 -0
  4. package/dist/src/cli/commands/hook.d.ts.map +1 -0
  5. package/dist/src/cli/commands/hook.js +61 -0
  6. package/dist/src/cli/commands/hook.js.map +1 -0
  7. package/dist/src/cli/commands/init.d.ts.map +1 -1
  8. package/dist/src/cli/commands/init.js +5 -0
  9. package/dist/src/cli/commands/init.js.map +1 -1
  10. package/dist/src/cli/commands/refresh-plugins.d.ts.map +1 -1
  11. package/dist/src/cli/commands/refresh-plugins.js +11 -1
  12. package/dist/src/cli/commands/refresh-plugins.js.map +1 -1
  13. package/dist/src/cli/commands/sync-setup.d.ts.map +1 -1
  14. package/dist/src/cli/commands/sync-setup.js +7 -3
  15. package/dist/src/cli/commands/sync-setup.js.map +1 -1
  16. package/dist/src/cli/helpers/issue-tracker/project-mapping-wizard.d.ts +9 -0
  17. package/dist/src/cli/helpers/issue-tracker/project-mapping-wizard.d.ts.map +1 -1
  18. package/dist/src/cli/helpers/issue-tracker/project-mapping-wizard.js +9 -3
  19. package/dist/src/cli/helpers/issue-tracker/project-mapping-wizard.js.map +1 -1
  20. package/dist/src/config/types.d.ts +2 -2
  21. package/dist/src/core/config/types.d.ts +18 -2
  22. package/dist/src/core/config/types.d.ts.map +1 -1
  23. package/dist/src/core/config/types.js.map +1 -1
  24. package/dist/src/core/hooks/handlers/hook-router.d.ts +19 -0
  25. package/dist/src/core/hooks/handlers/hook-router.d.ts.map +1 -0
  26. package/dist/src/core/hooks/handlers/hook-router.js +75 -0
  27. package/dist/src/core/hooks/handlers/hook-router.js.map +1 -0
  28. package/dist/src/core/hooks/handlers/index.d.ts +10 -0
  29. package/dist/src/core/hooks/handlers/index.d.ts.map +1 -0
  30. package/dist/src/core/hooks/handlers/index.js +9 -0
  31. package/dist/src/core/hooks/handlers/index.js.map +1 -0
  32. package/dist/src/core/hooks/handlers/post-tool-use-analytics.d.ts +11 -0
  33. package/dist/src/core/hooks/handlers/post-tool-use-analytics.d.ts.map +1 -0
  34. package/dist/src/core/hooks/handlers/post-tool-use-analytics.js +73 -0
  35. package/dist/src/core/hooks/handlers/post-tool-use-analytics.js.map +1 -0
  36. package/dist/src/core/hooks/handlers/post-tool-use.d.ts +11 -0
  37. package/dist/src/core/hooks/handlers/post-tool-use.d.ts.map +1 -0
  38. package/dist/src/core/hooks/handlers/post-tool-use.js +76 -0
  39. package/dist/src/core/hooks/handlers/post-tool-use.js.map +1 -0
  40. package/dist/src/core/hooks/handlers/pre-compact.d.ts +11 -0
  41. package/dist/src/core/hooks/handlers/pre-compact.d.ts.map +1 -0
  42. package/dist/src/core/hooks/handlers/pre-compact.js +77 -0
  43. package/dist/src/core/hooks/handlers/pre-compact.js.map +1 -0
  44. package/dist/src/core/hooks/handlers/pre-tool-use.d.ts +11 -0
  45. package/dist/src/core/hooks/handlers/pre-tool-use.d.ts.map +1 -0
  46. package/dist/src/core/hooks/handlers/pre-tool-use.js +318 -0
  47. package/dist/src/core/hooks/handlers/pre-tool-use.js.map +1 -0
  48. package/dist/src/core/hooks/handlers/session-start.d.ts +9 -0
  49. package/dist/src/core/hooks/handlers/session-start.d.ts.map +1 -0
  50. package/dist/src/core/hooks/handlers/session-start.js +111 -0
  51. package/dist/src/core/hooks/handlers/session-start.js.map +1 -0
  52. package/dist/src/core/hooks/handlers/stop-auto.d.ts +16 -0
  53. package/dist/src/core/hooks/handlers/stop-auto.d.ts.map +1 -0
  54. package/dist/src/core/hooks/handlers/stop-auto.js +122 -0
  55. package/dist/src/core/hooks/handlers/stop-auto.js.map +1 -0
  56. package/dist/src/core/hooks/handlers/stop-reflect.d.ts +14 -0
  57. package/dist/src/core/hooks/handlers/stop-reflect.d.ts.map +1 -0
  58. package/dist/src/core/hooks/handlers/stop-reflect.js +43 -0
  59. package/dist/src/core/hooks/handlers/stop-reflect.js.map +1 -0
  60. package/dist/src/core/hooks/handlers/stop-sync.d.ts +15 -0
  61. package/dist/src/core/hooks/handlers/stop-sync.d.ts.map +1 -0
  62. package/dist/src/core/hooks/handlers/stop-sync.js +68 -0
  63. package/dist/src/core/hooks/handlers/stop-sync.js.map +1 -0
  64. package/dist/src/core/hooks/handlers/types.d.ts +63 -0
  65. package/dist/src/core/hooks/handlers/types.d.ts.map +1 -0
  66. package/dist/src/core/hooks/handlers/types.js +27 -0
  67. package/dist/src/core/hooks/handlers/types.js.map +1 -0
  68. package/dist/src/core/hooks/handlers/user-prompt-submit.d.ts +14 -0
  69. package/dist/src/core/hooks/handlers/user-prompt-submit.d.ts.map +1 -0
  70. package/dist/src/core/hooks/handlers/user-prompt-submit.js +173 -0
  71. package/dist/src/core/hooks/handlers/user-prompt-submit.js.map +1 -0
  72. package/dist/src/core/hooks/handlers/utils.d.ts +25 -0
  73. package/dist/src/core/hooks/handlers/utils.d.ts.map +1 -0
  74. package/dist/src/core/hooks/handlers/utils.js +64 -0
  75. package/dist/src/core/hooks/handlers/utils.js.map +1 -0
  76. package/dist/src/core/increment/completion-validator.d.ts.map +1 -1
  77. package/dist/src/core/increment/completion-validator.js +32 -0
  78. package/dist/src/core/increment/completion-validator.js.map +1 -1
  79. package/dist/src/init/research/types.d.ts +1 -1
  80. package/dist/src/sync/sync-target-resolver.js.map +1 -1
  81. package/dist/src/utils/lock-manager.d.ts.map +1 -1
  82. package/dist/src/utils/lock-manager.js +5 -0
  83. package/dist/src/utils/lock-manager.js.map +1 -1
  84. package/dist/src/utils/plugin-copier.d.ts +10 -0
  85. package/dist/src/utils/plugin-copier.d.ts.map +1 -1
  86. package/dist/src/utils/plugin-copier.js +63 -35
  87. package/dist/src/utils/plugin-copier.js.map +1 -1
  88. package/package.json +1 -1
  89. package/plugins/specweave/agents/sw-closer.md +3 -2
  90. package/plugins/specweave/hooks/hooks.json +10 -10
  91. package/plugins/specweave/skills/code-reviewer/SKILL.md +180 -16
  92. package/plugins/specweave/skills/code-reviewer/agents/reviewer-comments.md +83 -0
  93. package/plugins/specweave/skills/code-reviewer/agents/reviewer-silent-failures.md +19 -0
  94. package/plugins/specweave/skills/code-reviewer/agents/reviewer-spec-compliance.md +19 -0
  95. package/plugins/specweave/skills/code-reviewer/agents/reviewer-tests.md +101 -0
  96. package/plugins/specweave/skills/code-reviewer/agents/reviewer-types.md +20 -0
  97. package/plugins/specweave/skills/done/SKILL.md +56 -21
  98. package/plugins/specweave/skills/grill/SKILL.md +1 -1
  99. package/plugins/specweave/skills/team-lead/agents/reviewer-logic.md +19 -0
  100. package/plugins/specweave/skills/team-lead/agents/reviewer-performance.md +20 -0
  101. package/plugins/specweave/skills/team-lead/agents/reviewer-security.md +20 -0
  102. package/src/templates/CLAUDE.md.template +7 -4
  103. package/plugins/specweave/hooks/README.md +0 -493
  104. package/plugins/specweave/hooks/_archive/stop-auto-v4-legacy.sh +0 -1319
  105. package/plugins/specweave/hooks/lib/common-setup.sh +0 -144
  106. package/plugins/specweave/hooks/lib/hook-errors.sh +0 -414
  107. package/plugins/specweave/hooks/lib/migrate-increment-work.sh +0 -245
  108. package/plugins/specweave/hooks/lib/resolve-package.sh +0 -146
  109. package/plugins/specweave/hooks/lib/scheduler-startup.sh +0 -135
  110. package/plugins/specweave/hooks/lib/score-increment.sh +0 -87
  111. package/plugins/specweave/hooks/lib/sync-spec-content.sh +0 -193
  112. package/plugins/specweave/hooks/lib/update-active-increment.sh +0 -95
  113. package/plugins/specweave/hooks/lib/update-status-line.sh +0 -233
  114. package/plugins/specweave/hooks/lib/validate-spec-status.sh +0 -171
  115. package/plugins/specweave/hooks/llm-judge-validator.sh +0 -219
  116. package/plugins/specweave/hooks/log-decision.sh +0 -168
  117. package/plugins/specweave/hooks/pre-compact.sh +0 -64
  118. package/plugins/specweave/hooks/startup-health-check.sh +0 -64
  119. package/plugins/specweave/hooks/stop-auto-v5.sh +0 -276
  120. package/plugins/specweave/hooks/stop-reflect.sh +0 -336
  121. package/plugins/specweave/hooks/stop-sync.sh +0 -283
  122. package/plugins/specweave/hooks/tests/test-auto-context-integration.sh +0 -126
  123. package/plugins/specweave/hooks/tests/test-stop-auto-enriched.sh +0 -128
  124. package/plugins/specweave/hooks/universal/dispatcher.mjs +0 -336
  125. package/plugins/specweave/hooks/universal/fail-fast-wrapper.sh +0 -325
  126. package/plugins/specweave/hooks/universal/hook-wrapper.cmd +0 -26
  127. package/plugins/specweave/hooks/universal/hook-wrapper.sh +0 -69
  128. package/plugins/specweave/hooks/universal/run-hook.sh +0 -20
  129. package/plugins/specweave/hooks/universal/session-start.cmd +0 -16
  130. package/plugins/specweave/hooks/universal/session-start.ps1 +0 -16
  131. package/plugins/specweave/hooks/user-prompt-submit.sh +0 -2550
  132. package/plugins/specweave/hooks/v2/detectors/lifecycle-detector.sh +0 -87
  133. package/plugins/specweave/hooks/v2/detectors/us-completion-detector.sh +0 -186
  134. package/plugins/specweave/hooks/v2/dispatchers/post-tool-use-analytics.sh +0 -83
  135. package/plugins/specweave/hooks/v2/dispatchers/post-tool-use.sh +0 -447
  136. package/plugins/specweave/hooks/v2/dispatchers/pre-tool-use.sh +0 -104
  137. package/plugins/specweave/hooks/v2/dispatchers/session-start.sh +0 -270
  138. package/plugins/specweave/hooks/v2/guards/completion-guard.sh +0 -14
  139. package/plugins/specweave/hooks/v2/guards/increment-duplicate-guard.sh +0 -14
  140. package/plugins/specweave/hooks/v2/guards/increment-existence-guard.sh +0 -240
  141. package/plugins/specweave/hooks/v2/guards/interview-enforcement-guard.sh +0 -171
  142. package/plugins/specweave/hooks/v2/guards/metadata-json-guard.sh +0 -14
  143. package/plugins/specweave/hooks/v2/guards/skill-chain-enforcement-guard.sh +0 -222
  144. package/plugins/specweave/hooks/v2/guards/spec-template-enforcement-guard.sh +0 -21
  145. package/plugins/specweave/hooks/v2/guards/spec-validation-guard.sh +0 -14
  146. package/plugins/specweave/hooks/v2/guards/status-completion-guard.sh +0 -84
  147. package/plugins/specweave/hooks/v2/guards/task-ac-sync-guard.sh +0 -475
  148. package/plugins/specweave/hooks/v2/guards/tdd-enforcement-guard.sh +0 -268
  149. package/plugins/specweave/hooks/v2/handlers/ac-sync-dispatcher.sh +0 -332
  150. package/plugins/specweave/hooks/v2/handlers/ac-validation-handler.sh +0 -50
  151. package/plugins/specweave/hooks/v2/handlers/github-sync-handler.sh +0 -347
  152. package/plugins/specweave/hooks/v2/handlers/living-docs-handler.sh +0 -83
  153. package/plugins/specweave/hooks/v2/handlers/living-specs-handler.sh +0 -268
  154. package/plugins/specweave/hooks/v2/handlers/project-bridge-handler.sh +0 -104
  155. package/plugins/specweave/hooks/v2/handlers/status-line-handler.sh +0 -165
  156. package/plugins/specweave/hooks/v2/handlers/status-update.sh +0 -61
  157. package/plugins/specweave/hooks/v2/handlers/universal-auto-create-dispatcher.sh +0 -270
  158. package/plugins/specweave/hooks/v2/integrations/ado-post-living-docs-update.sh +0 -367
  159. package/plugins/specweave/hooks/v2/integrations/ado-post-task.sh +0 -179
  160. package/plugins/specweave/hooks/v2/integrations/github-auto-create-handler.sh +0 -553
  161. package/plugins/specweave/hooks/v2/integrations/github-post-task.sh +0 -345
  162. package/plugins/specweave/hooks/v2/integrations/jira-post-task.sh +0 -180
  163. package/plugins/specweave/hooks/v2/lib/check-provider-enabled.sh +0 -52
  164. package/plugins/specweave/hooks/v2/queue/enqueue.sh +0 -81
  165. package/plugins/specweave/hooks/v2/session-end.sh +0 -139
  166. package/plugins/specweave/hooks/validate-skill-activations.sh +0 -227
@@ -1,270 +0,0 @@
1
- #!/bin/bash
2
- # session-start.sh - Session initialization dispatcher (ACTIVE HOOK)
3
- #
4
- # ✅ This is the ACTIVE session-start hook (configured in hooks.json)
5
- # Ultra-fast, non-blocking startup for every Claude Code session
6
- #
7
- # v1.0.127: AUTO-LOAD PLUGINS based on project type (React, Express, K8s, etc.)
8
- # v1.0.180: LSP language server check (detects missing binaries)
9
- #
10
- # Claude Code 2.1.2+ Enhancement:
11
- # - Reads agent_type from SessionStart input for agent-specific initialization
12
- # - Enables customized startup behavior based on which agent is running
13
- set +e
14
-
15
- [[ "${SPECWEAVE_DISABLE_HOOKS:-0}" == "1" ]] && exit 0
16
-
17
- # Find project root
18
- PROJECT_ROOT="$PWD"
19
- while [[ "$PROJECT_ROOT" != "/" ]] && [[ ! -f "$PROJECT_ROOT/.specweave/config.json" ]]; do
20
- PROJECT_ROOT=$(dirname "$PROJECT_ROOT")
21
- done
22
- [[ ! -f "$PROJECT_ROOT/.specweave/config.json" ]] && exit 0
23
-
24
- # ============================================================================
25
- # SESSION CLEANUP: ALWAYS clear auto-mode.json (CRITICAL for session-scoped auto)
26
- # Auto mode MUST be session-scoped - each new Claude Code session starts FRESH.
27
- # This ensures: Session A runs /sw:auto → closes → Session B starts CLEAN
28
- # ============================================================================
29
- STATE_DIR="$PROJECT_ROOT/.specweave/state"
30
- AUTO_MODE_FILE="$STATE_DIR/auto-mode.json"
31
-
32
- if [[ -f "$AUTO_MODE_FILE" ]]; then
33
- rm -f "$AUTO_MODE_FILE" 2>/dev/null
34
- rm -f "$STATE_DIR/.stop-auto-dedup" 2>/dev/null
35
- rm -f "$STATE_DIR/.stop-auto-dedup-prev" 2>/dev/null
36
- rm -f "$STATE_DIR/.stop-auto-turns" 2>/dev/null
37
- # Log cleanup (non-blocking, fire-and-forget)
38
- mkdir -p "$PROJECT_ROOT/.specweave/logs" 2>/dev/null
39
- echo "[$(date -u +%Y-%m-%dT%H:%M:%SZ)] SessionStart: Cleared auto-mode session files (session-scoped)" >> "$PROJECT_ROOT/.specweave/logs/session.log" 2>/dev/null
40
- fi
41
-
42
- # ============================================================================
43
- # CONTEXT PRESSURE RESET: Clear pressure state for fresh session budget (v1.0.262)
44
- # Ensures new sessions start at user's configured base budget level
45
- # ============================================================================
46
- rm -f "$STATE_DIR/context-pressure.json" 2>/dev/null
47
- rm -f "$STATE_DIR/.context-hash" 2>/dev/null
48
- rm -f "$STATE_DIR/prompt-health-alert.json" 2>/dev/null
49
-
50
- # ============================================================================
51
- # PROMPT BASELINE HEALTH CHECK (v1.0.268)
52
- # Calculates approximate baseline prompt size from controllable factors.
53
- # Warns user if baseline is dangerously high (>80K warning, >120K critical).
54
- # Writes prompt-health.json for dashboard consumption.
55
- # ============================================================================
56
- CLAUDE_MD_SIZE=0
57
- MEMORY_MD_SIZE=0
58
- SKILL_BUDGET="${SLASH_COMMAND_TOOL_CHAR_BUDGET:-15000}"
59
- [[ ! "$SKILL_BUDGET" =~ ^[0-9]+$ ]] && SKILL_BUDGET=15000
60
- SYSTEM_ESTIMATE=12000
61
- HOOK_PER_TURN=3000
62
-
63
- # Measure CLAUDE.md
64
- if [[ -f "$PROJECT_ROOT/CLAUDE.md" ]]; then
65
- CLAUDE_MD_SIZE=$(wc -c < "$PROJECT_ROOT/CLAUDE.md" 2>/dev/null | tr -d ' ')
66
- [[ ! "$CLAUDE_MD_SIZE" =~ ^[0-9]+$ ]] && CLAUDE_MD_SIZE=0
67
- fi
68
-
69
- # Measure global CLAUDE.md (user's global instructions)
70
- GLOBAL_CLAUDE="$HOME/.claude/CLAUDE.md"
71
- if [[ -f "$GLOBAL_CLAUDE" ]]; then
72
- _GC_SIZE=$(wc -c < "$GLOBAL_CLAUDE" 2>/dev/null | tr -d ' ')
73
- [[ "$_GC_SIZE" =~ ^[0-9]+$ ]] && MEMORY_MD_SIZE=$((_GC_SIZE))
74
- fi
75
-
76
- # Measure project-specific MEMORY.md
77
- _PROJECT_SLUG=$(echo "$PROJECT_ROOT" | sed 's|^/||;s|/|-|g')
78
- _PROJECT_MEMORY="$HOME/.claude/projects/-${_PROJECT_SLUG}/memory/MEMORY.md"
79
- if [[ -f "$_PROJECT_MEMORY" ]]; then
80
- _PM_SIZE=$(wc -c < "$_PROJECT_MEMORY" 2>/dev/null | tr -d ' ')
81
- [[ "$_PM_SIZE" =~ ^[0-9]+$ ]] && MEMORY_MD_SIZE=$((MEMORY_MD_SIZE + _PM_SIZE))
82
- fi
83
-
84
- BASELINE=$((CLAUDE_MD_SIZE + MEMORY_MD_SIZE + SKILL_BUDGET + SYSTEM_ESTIMATE + HOOK_PER_TURN))
85
-
86
- # Determine warning level
87
- WARNING_THRESHOLD=80000
88
- CRITICAL_THRESHOLD=120000
89
- WARNING_LEVEL="normal"
90
- if [[ $BASELINE -gt $CRITICAL_THRESHOLD ]]; then
91
- WARNING_LEVEL="critical"
92
- elif [[ $BASELINE -gt $WARNING_THRESHOLD ]]; then
93
- WARNING_LEVEL="warning"
94
- fi
95
-
96
- # Write health check to state for dashboard
97
- cat > "$STATE_DIR/prompt-health.json" <<EOF
98
- {"baseline":$BASELINE,"claudeMdSize":$CLAUDE_MD_SIZE,"memoryMdSize":$MEMORY_MD_SIZE,"skillBudget":$SKILL_BUDGET,"systemEstimate":$SYSTEM_ESTIMATE,"hookPerTurn":$HOOK_PER_TURN,"warningLevel":"$WARNING_LEVEL","checkedAt":"$(date -Iseconds)"}
99
- EOF
100
-
101
- # Emit warnings
102
- if [[ "$WARNING_LEVEL" == "critical" ]]; then
103
- echo "{\"continue\":true,\"systemMessage\":\"PROMPT HEALTH: CRITICAL - Baseline prompt size is ${BASELINE} chars ($((BASELINE / 1000))KB). CLAUDE.md=${CLAUDE_MD_SIZE}, MEMORY.md=${MEMORY_MD_SIZE}, Skills=${SKILL_BUDGET}. Risk of 'Prompt is too long' errors. Reduce MEMORY.md (<5KB), lower contextBudget.level, or reduce SLASH_COMMAND_TOOL_CHAR_BUDGET.\"}"
104
- elif [[ "$WARNING_LEVEL" == "warning" ]]; then
105
- echo "{\"continue\":true,\"systemMessage\":\"PROMPT HEALTH: Elevated baseline prompt size (${BASELINE} chars / $((BASELINE / 1000))KB). CLAUDE.md=${CLAUDE_MD_SIZE}, MEMORY.md=${MEMORY_MD_SIZE}. Consider reducing MEMORY.md or lowering contextBudget level if you see compaction warnings.\"}"
106
- fi
107
-
108
- # Log health check
109
- mkdir -p "$PROJECT_ROOT/.specweave/logs" 2>/dev/null
110
- echo "[$(date -Iseconds)] HEALTH_CHECK | baseline=$BASELINE | level=$WARNING_LEVEL | claude_md=$CLAUDE_MD_SIZE | memory_md=$MEMORY_MD_SIZE | skills=$SKILL_BUDGET" >> "$PROJECT_ROOT/.specweave/logs/prompt-health.log" 2>/dev/null
111
-
112
- # ============================================================================
113
- # PLUGIN CACHE: Do NOT delete - Claude Code manages its own plugin cache
114
- # v1.0.206: (REVERTED) Cache deletion broke plugin loading - installed_plugins.json
115
- # still referenced deleted paths, causing all commands/skills to fail
116
- # ============================================================================
117
-
118
- # ============================================================================
119
- # PLUGIN HEALTH: Ensure sw@specweave is enabled (guards against corruption)
120
- # v1.0.513: Claude Code's plugin CLI can corrupt enabledPlugins as a side
121
- # effect of install/uninstall operations (read-modify-write race, settings
122
- # sync after installed_plugins.json wipe). This fast check repairs it.
123
- # ============================================================================
124
- CLAUDE_SETTINGS="$HOME/.claude/settings.json"
125
- if command -v jq >/dev/null 2>&1 && [[ -f "$CLAUDE_SETTINGS" ]]; then
126
- SW_STATE=$(jq -r '.enabledPlugins["sw@specweave"]' "$CLAUDE_SETTINGS" 2>/dev/null)
127
- if [[ "$SW_STATE" != "true" ]]; then
128
- jq '.enabledPlugins["sw@specweave"] = true' "$CLAUDE_SETTINGS" > "${CLAUDE_SETTINGS}.tmp" && \
129
- mv "${CLAUDE_SETTINGS}.tmp" "$CLAUDE_SETTINGS" 2>/dev/null
130
- echo '{"continue":true,"systemMessage":"sw@specweave was disabled (corruption detected) — auto-repaired. Skills are now active."}'
131
- mkdir -p "$PROJECT_ROOT/.specweave/logs" 2>/dev/null
132
- echo "[$(date -Iseconds)] PLUGIN_HEALTH: Repaired sw@specweave (was: $SW_STATE)" >> "$PROJECT_ROOT/.specweave/logs/session.log" 2>/dev/null
133
- fi
134
- fi
135
-
136
- # Read stdin to extract agent_type (Claude Code 2.1.2+)
137
- INPUT=$(cat 2>/dev/null || echo '{}')
138
- AGENT_TYPE=""
139
- if command -v jq >/dev/null 2>&1; then
140
- AGENT_TYPE=$(echo "$INPUT" | jq -r '.agent_type // ""' 2>/dev/null || echo "")
141
- fi
142
-
143
- # Agent-specific initialization (Claude Code 2.1.2+)
144
- if [[ -n "$AGENT_TYPE" ]]; then
145
- STATE_DIR="$PROJECT_ROOT/.specweave/state"
146
- mkdir -p "$STATE_DIR" 2>/dev/null
147
-
148
- # Store agent type for other hooks to use
149
- echo "$AGENT_TYPE" > "$STATE_DIR/.current-agent-type" 2>/dev/null
150
-
151
- # Agent-specific startup messages
152
- case "$AGENT_TYPE" in
153
- sw:pm|sw-pm)
154
- echo '{"continue":true,"systemMessage":"🎯 PM Agent: Product Management context loaded. Focus on user stories, acceptance criteria, and business value."}'
155
- ;;
156
- sw:architect|sw-architect)
157
- echo '{"continue":true,"systemMessage":"🏗️ Architect Agent: Technical design context loaded. Focus on ADRs, system design, and architecture patterns."}'
158
- ;;
159
- esac
160
- fi
161
-
162
- # Hook directory for finding other scripts
163
- HOOK_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
164
-
165
- # === MCP Connection Health Check ===
166
- # Check for recent MCP drops that could cause session hangs
167
- CLAUDE_DEBUG="$HOME/.claude/debug/latest"
168
- if [[ -f "$CLAUDE_DEBUG" ]]; then
169
- # Count MCP drops in last debug log (only check last 500 lines for speed)
170
- MCP_DROPS=$(tail -500 "$CLAUDE_DEBUG" 2>/dev/null | grep -c "WS-IDE connection dropped" 2>/dev/null | head -1 || echo "0")
171
- MCP_DROPS="${MCP_DROPS//[^0-9]/}" # Strip non-numeric characters
172
- [[ -z "$MCP_DROPS" ]] && MCP_DROPS=0
173
- if [[ "$MCP_DROPS" -gt 2 ]]; then
174
- echo "{\"continue\":true,\"systemMessage\":\"⚠️ MCP Connection Issues Detected: $MCP_DROPS drops in last session. Consider: (1) Restart VS Code Extension Host (Cmd+Shift+P), (2) Close extra files, (3) Use terminal mode if issues persist.\"}"
175
- fi
176
- fi
177
-
178
- # Script paths (HOOK_DIR already defined above)
179
- # HOOK_DIR is hooks/v2/dispatchers (where this script is)
180
- # Need to go up THREE levels to reach plugin root: dispatchers -> v2 -> hooks -> plugin
181
- PLUGIN_ROOT="$(cd "$HOOK_DIR/../../.." && pwd)"
182
- SCRIPTS_DIR="$PLUGIN_ROOT/scripts"
183
- SCHEDULER_STARTUP="$PLUGIN_ROOT/lib/scheduler-startup.sh"
184
- CLEANUP_SCRIPT="$SCRIPTS_DIR/cleanup-legacy-state.sh"
185
-
186
- # === Dashboard Cache Validation (v0.34.0 - Instant Status Commands) ===
187
- # Rebuild cache if missing or schema version mismatch
188
- CACHE_FILE="$PROJECT_ROOT/.specweave/state/dashboard.json"
189
- REBUILD_SCRIPT="$SCRIPTS_DIR/rebuild-dashboard-cache.sh"
190
- CACHE_VERSION_EXPECTED=1
191
-
192
- if [[ -f "$REBUILD_SCRIPT" ]]; then
193
- SHOULD_REBUILD=false
194
-
195
- if [[ ! -f "$CACHE_FILE" ]]; then
196
- # Cache missing - rebuild
197
- SHOULD_REBUILD=true
198
- elif command -v jq >/dev/null 2>&1; then
199
- # Check version (only if jq available)
200
- CACHE_VERSION=$(jq -r '.version // 0' "$CACHE_FILE" 2>/dev/null)
201
- if [[ "$CACHE_VERSION" != "$CACHE_VERSION_EXPECTED" ]]; then
202
- SHOULD_REBUILD=true
203
- fi
204
- fi
205
-
206
- if [[ "$SHOULD_REBUILD" == "true" ]]; then
207
- # Rebuild in background to not block session start
208
- nohup bash "$REBUILD_SCRIPT" --quiet > /dev/null 2>&1 &
209
- disown 2>/dev/null
210
- fi
211
- fi
212
-
213
- # === AUTO-LOAD PLUGINS REMOVED (v1.0.159) ===
214
- # Project-file-based detection (specweave detect-project) was removed.
215
- #
216
- # REASON: Users want plugins installed ONLY when LLM determines they need them
217
- # for a specific BUILD task, not based on project file scanning.
218
- #
219
- # Plugin auto-loading now happens ONLY in user-prompt-submit.sh via LLM detection.
220
- # When user submits a prompt like "Build React dashboard", the LLM analyzes
221
- # the request and installs relevant plugins (backend, testing, etc.)
222
- #
223
- # To install plugins manually: vskill install --repo anton-abyzov/vskill --plugin backend
224
-
225
- # === LEGACY STATE CLEANUP (v1.0.148) ===
226
- # Clean up old processor state files on session start
227
- # This is a one-time migration - old files are removed automatically
228
- if [[ -f "$CLEANUP_SCRIPT" ]]; then
229
- bash "$CLEANUP_SCRIPT" 2>/dev/null || true
230
- fi
231
-
232
- # Check for due scheduled jobs (non-blocking)
233
- if [[ -f "$SCHEDULER_STARTUP" ]]; then
234
- bash "$SCHEDULER_STARTUP" 2>/dev/null || true
235
- fi
236
-
237
- # === LSP OPERATIONS (v1.0.197) ===
238
- # LSP check and warm-up ONLY run if user has explicitly enabled LSP via ENABLE_LSP_TOOL=1
239
- # This avoids wasted background work for users who don't use LSP features
240
- #
241
- # Why gate on ENABLE_LSP_TOOL:
242
- # 1. LSP requires explicit setup (language server binaries, Claude plugins)
243
- # 2. Not all users need semantic code intelligence
244
- # 3. Background processes consume resources
245
- # 4. LSP warm-up is triggered on-demand when user prompt contains LSP keywords
246
- #
247
- # To enable: Add "export ENABLE_LSP_TOOL=1" to ~/.zshrc or ~/.bashrc
248
- if [[ -n "${ENABLE_LSP_TOOL:-}" ]]; then
249
- # === LSP LANGUAGE SERVER CHECK ===
250
- # Verify language server binaries are installed for dominant project languages
251
- LSP_CHECK_SCRIPT="$SCRIPTS_DIR/lsp-check.sh"
252
- if [[ -x "$LSP_CHECK_SCRIPT" ]] || [[ -f "$LSP_CHECK_SCRIPT" ]]; then
253
- mkdir -p "$PROJECT_ROOT/.specweave/logs" 2>/dev/null
254
- nohup bash "$LSP_CHECK_SCRIPT" "$PROJECT_ROOT" \
255
- >> "$PROJECT_ROOT/.specweave/logs/lsp-check.log" 2>&1 &
256
- disown 2>/dev/null
257
- fi
258
-
259
- # NOTE: LSP warm-up is NOT done here on session start
260
- # Instead, it's triggered lazily by user-prompt-submit.sh when:
261
- # 1. User prompt contains LSP keywords ("find references", "go to definition", etc.)
262
- # 2. AND warm-up hasn't been done yet this session
263
- # This avoids warming up LSP for sessions that never use it
264
- fi
265
-
266
- # Session watchdog REMOVED (ADR-0224)
267
- # VSCode extension manages session lifecycle - no daemon needed
268
- # For stuck sessions: Close Claude Code or restart Extension Host
269
-
270
- exit 0
@@ -1,14 +0,0 @@
1
- #!/bin/bash
2
- # completion-guard.sh - DISABLED (v1.0.38)
3
- #
4
- # This guard was converted to WARNING-only in v1.0.37, and now completely
5
- # disabled in v1.0.38 per user feedback: "you MUST NEVER block such operations"
6
- #
7
- # Completion workflow should be handled by agents/scripts with proper business logic,
8
- # not by hooks that can interfere with file operations.
9
- #
10
- # This guard now does NOTHING - just allows all operations.
11
-
12
- set +e
13
- echo '{"decision":"allow"}'
14
- exit 0
@@ -1,14 +0,0 @@
1
- #!/bin/bash
2
- # increment-duplicate-guard.sh - DISABLED (v1.0.38)
3
- #
4
- # This guard was converted to WARNING-only in v1.0.37, and now completely
5
- # disabled in v1.0.38 per user feedback: "you MUST NEVER block such operations"
6
- #
7
- # Duplicate detection should be handled by agents/scripts with proper business logic,
8
- # not by hooks that can interfere with file operations.
9
- #
10
- # This guard now does NOTHING - just allows all operations.
11
-
12
- set +e
13
- echo '{"decision":"allow"}'
14
- exit 0
@@ -1,240 +0,0 @@
1
- #!/bin/bash
2
- # increment-existence-guard.sh - Mode-aware guard for team creation
3
- #
4
- # PURPOSE:
5
- # Enforces spec-first principle for IMPLEMENTATION teams while allowing
6
- # non-implementation teams (review, brainstorm, analysis) to proceed freely.
7
- #
8
- # MODES:
9
- # - implementation (default): Requires increment with substantive spec.md
10
- # - review: PR reviews, code audits, architecture reviews — no increment needed
11
- # - brainstorm: Multi-perspective ideation sessions — no increment needed
12
- # - analysis: Codebase research, exploration, audits — no increment needed
13
- # - research: Codebase investigation and web research — no increment needed
14
- # - plan: Parallel planning with PM + Architect — creates its own increment
15
- #
16
- # MODE DETECTION (in priority order):
17
- # 1. team_name prefix: review-*, brainstorm-*, analysis-*, audit-*, research-*, plan-*
18
- # 2. description keywords: "review", "brainstorm", "analyze", "audit", "explore",
19
- # "ideate", "research", "planning", "pr #", "pull request", "code review",
20
- # "architecture review"
21
- # 3. Default: implementation mode (requires increment)
22
- #
23
- # DETECTION (implementation mode only):
24
- # - Fires on TeamCreate tool calls (global via hooks.json + skill-scoped via frontmatter)
25
- # - Scans .specweave/increments/ and repositories/*/*/.specweave/increments/
26
- # - Requires spec.md to pass ALL checks:
27
- # 1. File exists and has >500 bytes of content
28
- # 2. No template markers (exact strings or {{VAR}} patterns)
29
- # 3. At least one acceptance criterion (AC- pattern)
30
- # - BLOCKS if no qualifying increment found
31
- # - ALLOWS if at least one passes all checks
32
- #
33
- # @since 1.0.342
34
- # @updated 1.0.417 — multi-mode support
35
-
36
- set -e
37
-
38
- INPUT=$(cat)
39
- TOOL_NAME=$(echo "$INPUT" | jq -r '.tool_name // .toolName // ""')
40
-
41
- # Only check TeamCreate
42
- if [[ "$TOOL_NAME" != "TeamCreate" ]]; then
43
- echo '{"decision":"allow"}'
44
- exit 0
45
- fi
46
-
47
- # Env var bypass — allows team creation without increment (e.g. specweave team --no-increment)
48
- if [[ "${SPECWEAVE_NO_INCREMENT:-}" == "1" ]]; then
49
- echo '{"decision":"allow"}'
50
- exit 0
51
- fi
52
-
53
- # --- MODE DETECTION ---
54
- # Extract team_name and description from the tool input
55
- TEAM_NAME=$(echo "$INPUT" | jq -r '.tool_input.team_name // .input.team_name // ""' 2>/dev/null)
56
- DESCRIPTION=$(echo "$INPUT" | jq -r '.tool_input.description // .input.description // ""' 2>/dev/null)
57
-
58
- # Lowercase for matching
59
- TEAM_NAME_LC=$(echo "$TEAM_NAME" | tr '[:upper:]' '[:lower:]')
60
- DESCRIPTION_LC=$(echo "$DESCRIPTION" | tr '[:upper:]' '[:lower:]')
61
-
62
- # Check 1: team_name prefix
63
- NON_IMPL_MODE=false
64
- case "$TEAM_NAME_LC" in
65
- review-*|brainstorm-*|analysis-*|audit-*|explore-*|ideate-*|research-*|plan-*)
66
- NON_IMPL_MODE=true
67
- ;;
68
- esac
69
-
70
- # Check 2: description keywords (only if prefix didn't match)
71
- if [[ "$NON_IMPL_MODE" == "false" ]]; then
72
- NON_IMPL_KEYWORDS=(
73
- "review"
74
- "brainstorm"
75
- "analyze"
76
- "audit"
77
- "explore"
78
- "ideate"
79
- "pull request"
80
- "pr #"
81
- "pr review"
82
- "code review"
83
- "architecture review"
84
- "security audit"
85
- "performance audit"
86
- "code audit"
87
- "ideation"
88
- "exploration"
89
- "research"
90
- "planning"
91
- "perspectives"
92
- "devil's advocate"
93
- "pros and cons"
94
- )
95
-
96
- for keyword in "${NON_IMPL_KEYWORDS[@]}"; do
97
- if [[ "$DESCRIPTION_LC" == *"$keyword"* ]]; then
98
- NON_IMPL_MODE=true
99
- break
100
- fi
101
- done
102
- fi
103
-
104
- # Non-implementation modes bypass the spec check entirely
105
- if [[ "$NON_IMPL_MODE" == "true" ]]; then
106
- echo '{"decision":"allow"}'
107
- exit 0
108
- fi
109
-
110
- # --- IMPLEMENTATION MODE: Require increment with spec ---
111
-
112
- # Template markers — spec.md with these is a template, not a real spec
113
- TEMPLATE_MARKERS=(
114
- "[Story Title]"
115
- "[user type]"
116
- "[goal]"
117
- "[benefit]"
118
- "[Specific, testable criterion]"
119
- "[Component 1]"
120
- "[High-level description"
121
- "{{RESOLVED_PROJECT}}"
122
- "TEMPLATE FILE"
123
- )
124
-
125
- check_spec() {
126
- local spec_path="$1"
127
- if [[ ! -f "$spec_path" ]]; then
128
- return 1
129
- fi
130
-
131
- # Check 1: Minimum size (500 bytes — a real spec with user stories and ACs)
132
- local size
133
- size=$(wc -c < "$spec_path" 2>/dev/null || echo "0")
134
- size=$(echo "$size" | tr -d '[:space:]')
135
- if [[ "$size" -le 500 ]]; then
136
- return 1
137
- fi
138
-
139
- # Check 2: Scan FULL file for template markers (not just first 10 lines)
140
- local content
141
- content=$(cat "$spec_path" 2>/dev/null || echo "")
142
-
143
- # Exact template marker strings
144
- for marker in "${TEMPLATE_MARKERS[@]}"; do
145
- if [[ "$content" == *"$marker"* ]]; then
146
- return 1
147
- fi
148
- done
149
-
150
- # Regex: {{UPPERCASE_VAR}} mustache placeholders (e.g., {{FEATURE_NAME}})
151
- if echo "$content" | grep -qE '\{\{[A-Z_]+\}\}' 2>/dev/null; then
152
- return 1
153
- fi
154
-
155
- # Regex: High count of [Bracket Placeholders] suggests unfilled template
156
- # (threshold: 4+ to avoid false positives from markdown links [text](url))
157
- local bracket_count
158
- bracket_count=$(echo "$content" | grep -cE '\[[A-Z][^]]{2,}\]' 2>/dev/null || true)
159
- bracket_count=$(echo "$bracket_count" | tail -1 | tr -d '[:space:]')
160
- if [[ -n "$bracket_count" ]] && [[ "$bracket_count" -ge 4 ]]; then
161
- return 1
162
- fi
163
-
164
- # Check 3: Structural completeness — at least one acceptance criterion
165
- if ! grep -qE 'AC-US[0-9]+-[0-9]+|AC-[0-9]+' "$spec_path" 2>/dev/null; then
166
- return 1
167
- fi
168
-
169
- return 0
170
- }
171
-
172
- # Search for qualifying increments
173
- FOUND=false
174
-
175
- # Detect project root via walk-up
176
- _DIR="$PWD"
177
- _LIMIT=0
178
- while [[ "$_DIR" != "/" ]] && [[ ! -f "$_DIR/.specweave/config.json" ]] && [[ $_LIMIT -lt 50 ]]; do
179
- _DIR=$(dirname "$_DIR")
180
- _LIMIT=$((_LIMIT + 1))
181
- done
182
- _ROOT="$_DIR"
183
-
184
- # Single-repo increments
185
- if [[ -d "$_ROOT/.specweave/increments" ]]; then
186
- while IFS= read -r spec; do
187
- if check_spec "$spec"; then
188
- FOUND=true
189
- break
190
- fi
191
- done < <(find "$_ROOT/.specweave/increments" -maxdepth 2 -name "spec.md" 2>/dev/null)
192
- fi
193
-
194
- # Multi-repo increments
195
- if [[ "$FOUND" == "false" ]] && [[ -d "$_ROOT/repositories" ]]; then
196
- while IFS= read -r spec; do
197
- if check_spec "$spec"; then
198
- FOUND=true
199
- break
200
- fi
201
- done < <(find "$_ROOT/repositories" -path "*/.specweave/increments/*/spec.md" -maxdepth 6 2>/dev/null)
202
- fi
203
-
204
- if [[ "$FOUND" == "true" ]]; then
205
- echo '{"decision":"allow"}'
206
- exit 0
207
- fi
208
-
209
- # BLOCK — no qualifying increment found (implementation mode only)
210
- REASON="SPEC-FIRST ENFORCEMENT: Increment Required Before Team Creation
211
-
212
- TeamCreate CANNOT proceed without an existing increment with a substantive spec.md.
213
- This requirement applies to IMPLEMENTATION teams only.
214
-
215
- No qualifying increment found. A valid spec.md must have:
216
- - At least 500 bytes of real content (not templates)
217
- - No unfilled template markers or {{PLACEHOLDER}} patterns
218
- - At least one acceptance criterion (AC-USx-xx pattern)
219
-
220
- Searched:
221
- - .specweave/increments/*/spec.md
222
- - repositories/*/*/.specweave/increments/*/spec.md
223
-
224
- REQUIRED ACTION:
225
- 1. Run: /sw:increment \"your feature description\"
226
- 2. Review and approve the spec, plan, and tasks
227
- 3. THEN run: /sw:team-lead to parallelize execution
228
-
229
- ALTERNATIVE: For non-implementation work, use a mode-prefixed team name:
230
- - review-* → PR reviews, code audits (no increment needed)
231
- - brainstorm-* → Ideation sessions (no increment needed)
232
- - analysis-* → Research and exploration (no increment needed)
233
- - research-* → Codebase research and investigation (no increment needed)
234
- - plan-* → Parallel planning with PM + Architect (creates increment)
235
-
236
- Workflow: /sw:increment → /sw:team-lead → /sw:done"
237
-
238
- REASON_ESCAPED=$(echo "$REASON" | jq -Rs .)
239
- echo "{\"decision\":\"block\",\"reason\":${REASON_ESCAPED}}"
240
- exit 0