specweave 0.24.1 → 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 (173) hide show
  1. package/CLAUDE.md +106 -0
  2. package/README.md +34 -0
  3. package/dist/src/cli/commands/init.d.ts.map +1 -1
  4. package/dist/src/cli/commands/init.js +80 -41
  5. package/dist/src/cli/commands/init.js.map +1 -1
  6. package/dist/src/cli/helpers/issue-tracker/github-multi-repo.d.ts +5 -2
  7. package/dist/src/cli/helpers/issue-tracker/github-multi-repo.d.ts.map +1 -1
  8. package/dist/src/cli/helpers/issue-tracker/github-multi-repo.js +72 -6
  9. package/dist/src/cli/helpers/issue-tracker/github-multi-repo.js.map +1 -1
  10. package/dist/src/cli/helpers/issue-tracker/github.d.ts +2 -1
  11. package/dist/src/cli/helpers/issue-tracker/github.d.ts.map +1 -1
  12. package/dist/src/cli/helpers/issue-tracker/github.js +4 -3
  13. package/dist/src/cli/helpers/issue-tracker/github.js.map +1 -1
  14. package/dist/src/cli/helpers/issue-tracker/index.d.ts.map +1 -1
  15. package/dist/src/cli/helpers/issue-tracker/index.js +26 -9
  16. package/dist/src/cli/helpers/issue-tracker/index.js.map +1 -1
  17. package/dist/src/cli/helpers/issue-tracker/types.d.ts +2 -1
  18. package/dist/src/cli/helpers/issue-tracker/types.d.ts.map +1 -1
  19. package/dist/src/cli/helpers/issue-tracker/types.js.map +1 -1
  20. package/dist/src/config/types.d.ts +24 -24
  21. package/dist/src/core/config/types.d.ts +25 -0
  22. package/dist/src/core/config/types.d.ts.map +1 -1
  23. package/dist/src/core/config/types.js +6 -0
  24. package/dist/src/core/config/types.js.map +1 -1
  25. package/dist/src/core/repo-structure/git-error-handler.d.ts +37 -0
  26. package/dist/src/core/repo-structure/git-error-handler.d.ts.map +1 -0
  27. package/dist/src/core/repo-structure/git-error-handler.js +214 -0
  28. package/dist/src/core/repo-structure/git-error-handler.js.map +1 -0
  29. package/dist/src/core/repo-structure/git-provider.d.ts +183 -0
  30. package/dist/src/core/repo-structure/git-provider.d.ts.map +1 -0
  31. package/dist/src/core/repo-structure/git-provider.js +57 -0
  32. package/dist/src/core/repo-structure/git-provider.js.map +1 -0
  33. package/dist/src/core/repo-structure/github-validator.d.ts +1 -0
  34. package/dist/src/core/repo-structure/github-validator.d.ts.map +1 -1
  35. package/dist/src/core/repo-structure/github-validator.js +35 -9
  36. package/dist/src/core/repo-structure/github-validator.js.map +1 -1
  37. package/dist/src/core/repo-structure/platform-registry.d.ts +114 -0
  38. package/dist/src/core/repo-structure/platform-registry.d.ts.map +1 -0
  39. package/dist/src/core/repo-structure/platform-registry.js +195 -0
  40. package/dist/src/core/repo-structure/platform-registry.js.map +1 -0
  41. package/dist/src/core/repo-structure/prompt-consolidator.d.ts +30 -0
  42. package/dist/src/core/repo-structure/prompt-consolidator.d.ts.map +1 -1
  43. package/dist/src/core/repo-structure/prompt-consolidator.js +69 -0
  44. package/dist/src/core/repo-structure/prompt-consolidator.js.map +1 -1
  45. package/dist/src/core/repo-structure/providers/bitbucket-provider.d.ts +54 -0
  46. package/dist/src/core/repo-structure/providers/bitbucket-provider.d.ts.map +1 -0
  47. package/dist/src/core/repo-structure/providers/bitbucket-provider.js +104 -0
  48. package/dist/src/core/repo-structure/providers/bitbucket-provider.js.map +1 -0
  49. package/dist/src/core/repo-structure/providers/github-provider.d.ts +53 -0
  50. package/dist/src/core/repo-structure/providers/github-provider.d.ts.map +1 -0
  51. package/dist/src/core/repo-structure/providers/github-provider.js +239 -0
  52. package/dist/src/core/repo-structure/providers/github-provider.js.map +1 -0
  53. package/dist/src/core/repo-structure/providers/gitlab-provider.d.ts +50 -0
  54. package/dist/src/core/repo-structure/providers/gitlab-provider.d.ts.map +1 -0
  55. package/dist/src/core/repo-structure/providers/gitlab-provider.js +97 -0
  56. package/dist/src/core/repo-structure/providers/gitlab-provider.js.map +1 -0
  57. package/dist/src/core/repo-structure/providers/index.d.ts +33 -0
  58. package/dist/src/core/repo-structure/providers/index.d.ts.map +1 -0
  59. package/dist/src/core/repo-structure/providers/index.js +60 -0
  60. package/dist/src/core/repo-structure/providers/index.js.map +1 -0
  61. package/dist/src/core/repo-structure/repo-bulk-discovery.d.ts +33 -0
  62. package/dist/src/core/repo-structure/repo-bulk-discovery.d.ts.map +1 -0
  63. package/dist/src/core/repo-structure/repo-bulk-discovery.js +275 -0
  64. package/dist/src/core/repo-structure/repo-bulk-discovery.js.map +1 -0
  65. package/dist/src/core/repo-structure/repo-structure-manager.d.ts +18 -2
  66. package/dist/src/core/repo-structure/repo-structure-manager.d.ts.map +1 -1
  67. package/dist/src/core/repo-structure/repo-structure-manager.js +303 -85
  68. package/dist/src/core/repo-structure/repo-structure-manager.js.map +1 -1
  69. package/dist/src/core/repo-structure/url-generator.d.ts +80 -0
  70. package/dist/src/core/repo-structure/url-generator.d.ts.map +1 -0
  71. package/dist/src/core/repo-structure/url-generator.js +110 -0
  72. package/dist/src/core/repo-structure/url-generator.js.map +1 -0
  73. package/dist/src/init/architecture/types.d.ts +6 -6
  74. package/dist/src/utils/plugin-validator.d.ts.map +1 -1
  75. package/dist/src/utils/plugin-validator.js +15 -14
  76. package/dist/src/utils/plugin-validator.js.map +1 -1
  77. package/package.json +4 -4
  78. package/plugins/specweave/.claude-plugin/plugin.json +4 -4
  79. package/plugins/specweave/agents/pm/AGENT.md +2 -0
  80. package/plugins/specweave/commands/specweave-do.md +0 -47
  81. package/plugins/specweave/commands/specweave-increment.md +0 -82
  82. package/plugins/specweave/commands/specweave-next.md +0 -47
  83. package/plugins/specweave/hooks/post-task-completion.sh +67 -6
  84. package/plugins/specweave/hooks/pre-edit-spec.sh +11 -0
  85. package/plugins/specweave/hooks/pre-task-completion.sh +69 -2
  86. package/plugins/specweave/hooks/pre-write-spec.sh +11 -0
  87. package/plugins/specweave/skills/increment-planner/SKILL.md +124 -4
  88. package/plugins/specweave-ado/lib/ado-multi-project-sync.js +0 -1
  89. package/plugins/specweave-jira/lib/enhanced-jira-sync.js +3 -3
  90. package/plugins/specweave/agents/pm/AGENT.md.bak +0 -1893
  91. package/plugins/specweave/hooks/docs-changed.sh.backup +0 -79
  92. package/plugins/specweave/hooks/human-input-required.sh.backup +0 -75
  93. package/plugins/specweave/hooks/lib/migrate-increment-work.sh.bak +0 -245
  94. package/plugins/specweave/hooks/lib/sync-spec-content.sh.bak +0 -149
  95. package/plugins/specweave/hooks/lib/validate-spec-status.sh.bak +0 -163
  96. package/plugins/specweave/hooks/post-first-increment.sh.backup +0 -61
  97. package/plugins/specweave/hooks/post-first-increment.sh.bak +0 -61
  98. package/plugins/specweave/hooks/post-increment-change.sh.backup +0 -98
  99. package/plugins/specweave/hooks/post-increment-completion.sh.backup +0 -231
  100. package/plugins/specweave/hooks/post-increment-planning.sh.backup +0 -1048
  101. package/plugins/specweave/hooks/post-increment-status-change.sh.backup +0 -147
  102. package/plugins/specweave/hooks/post-spec-update.sh.backup +0 -158
  103. package/plugins/specweave/hooks/post-spec-update.sh.bak +0 -158
  104. package/plugins/specweave/hooks/post-user-story-complete.sh.backup +0 -179
  105. package/plugins/specweave/hooks/post-user-story-complete.sh.bak +0 -179
  106. package/plugins/specweave/hooks/pre-command-deduplication.sh.backup +0 -83
  107. package/plugins/specweave/hooks/pre-command-deduplication.sh.bak +0 -83
  108. package/plugins/specweave/hooks/pre-implementation.sh.backup +0 -67
  109. package/plugins/specweave/hooks/pre-task-completion.sh.backup +0 -194
  110. package/plugins/specweave/hooks/pre-tool-use.sh.backup +0 -133
  111. package/plugins/specweave/hooks/user-prompt-submit.sh.backup +0 -386
  112. package/plugins/specweave/hooks/user-prompt-submit.sh.bak +0 -386
  113. package/plugins/specweave/lib/hooks/auto-transition.js.bak +0 -50
  114. package/plugins/specweave/lib/hooks/auto-transition.ts.bak +0 -84
  115. package/plugins/specweave/lib/hooks/git-diff-analyzer.d.js.bak +0 -0
  116. package/plugins/specweave/lib/hooks/git-diff-analyzer.d.ts.bak +0 -89
  117. package/plugins/specweave/lib/hooks/git-diff-analyzer.js.bak +0 -142
  118. package/plugins/specweave/lib/hooks/git-diff-analyzer.ts.bak +0 -269
  119. package/plugins/specweave/lib/hooks/invoke-translator-skill.d.js.bak +0 -0
  120. package/plugins/specweave/lib/hooks/invoke-translator-skill.d.ts.bak +0 -60
  121. package/plugins/specweave/lib/hooks/invoke-translator-skill.js.bak +0 -155
  122. package/plugins/specweave/lib/hooks/invoke-translator-skill.ts.bak +0 -264
  123. package/plugins/specweave/lib/hooks/prepare-reflection-context.d.js.bak +0 -0
  124. package/plugins/specweave/lib/hooks/prepare-reflection-context.d.ts.bak +0 -42
  125. package/plugins/specweave/lib/hooks/prepare-reflection-context.js.bak +0 -110
  126. package/plugins/specweave/lib/hooks/prepare-reflection-context.ts.bak +0 -178
  127. package/plugins/specweave/lib/hooks/reflection-config-loader.d.js.bak +0 -0
  128. package/plugins/specweave/lib/hooks/reflection-config-loader.d.ts.bak +0 -45
  129. package/plugins/specweave/lib/hooks/reflection-config-loader.js.bak +0 -92
  130. package/plugins/specweave/lib/hooks/reflection-config-loader.ts.bak +0 -156
  131. package/plugins/specweave/lib/hooks/reflection-parser.d.js.bak +0 -0
  132. package/plugins/specweave/lib/hooks/reflection-parser.d.ts.bak +0 -33
  133. package/plugins/specweave/lib/hooks/reflection-parser.js.bak +0 -301
  134. package/plugins/specweave/lib/hooks/reflection-parser.ts.bak +0 -484
  135. package/plugins/specweave/lib/hooks/reflection-prompt-builder.d.js.bak +0 -0
  136. package/plugins/specweave/lib/hooks/reflection-prompt-builder.d.ts.bak +0 -56
  137. package/plugins/specweave/lib/hooks/reflection-prompt-builder.js.bak +0 -182
  138. package/plugins/specweave/lib/hooks/reflection-prompt-builder.ts.bak +0 -306
  139. package/plugins/specweave/lib/hooks/reflection-storage.d.js.bak +0 -0
  140. package/plugins/specweave/lib/hooks/reflection-storage.d.ts.bak +0 -64
  141. package/plugins/specweave/lib/hooks/reflection-storage.js.bak +0 -231
  142. package/plugins/specweave/lib/hooks/reflection-storage.ts.bak +0 -369
  143. package/plugins/specweave/lib/hooks/run-self-reflection.d.js.bak +0 -0
  144. package/plugins/specweave/lib/hooks/run-self-reflection.d.ts.bak +0 -43
  145. package/plugins/specweave/lib/hooks/run-self-reflection.js.bak +0 -132
  146. package/plugins/specweave/lib/hooks/run-self-reflection.ts.bak +0 -258
  147. package/plugins/specweave/lib/hooks/sync-cache.js.bak +0 -294
  148. package/plugins/specweave/lib/hooks/sync-living-docs.d.js.bak +0 -1
  149. package/plugins/specweave/lib/hooks/sync-living-docs.d.ts.bak +0 -27
  150. package/plugins/specweave/lib/hooks/sync-living-docs.js.bak +0 -339
  151. package/plugins/specweave/lib/hooks/sync-us-tasks.js.bak +0 -476
  152. package/plugins/specweave/lib/hooks/translate-file.d.js.bak +0 -0
  153. package/plugins/specweave/lib/hooks/translate-file.d.ts.bak +0 -59
  154. package/plugins/specweave/lib/hooks/translate-file.js.bak +0 -289
  155. package/plugins/specweave/lib/hooks/translate-file.ts.bak +0 -428
  156. package/plugins/specweave/lib/hooks/translate-living-docs.d.js.bak +0 -0
  157. package/plugins/specweave/lib/hooks/translate-living-docs.d.ts.bak +0 -13
  158. package/plugins/specweave/lib/hooks/translate-living-docs.js.bak +0 -119
  159. package/plugins/specweave/lib/hooks/translate-living-docs.ts.bak +0 -224
  160. package/plugins/specweave/lib/hooks/update-ac-status.js.bak +0 -51
  161. package/plugins/specweave/lib/hooks/update-ac-status.ts.bak +0 -103
  162. package/plugins/specweave/lib/hooks/update-tasks-md.d.js.bak +0 -1
  163. package/plugins/specweave/lib/hooks/update-tasks-md.d.ts.bak +0 -29
  164. package/plugins/specweave/lib/hooks/update-tasks-md.js.bak +0 -296
  165. package/plugins/specweave/lib/hooks/update-tasks-md.ts.bak +0 -489
  166. package/plugins/specweave-ado/hooks/post-living-docs-update.sh.backup +0 -353
  167. package/plugins/specweave-ado/hooks/post-task-completion.sh.backup +0 -172
  168. package/plugins/specweave-ado/lib/enhanced-ado-sync.js +0 -170
  169. package/plugins/specweave-github/hooks/.specweave/logs/hooks-debug.log +0 -228
  170. package/plugins/specweave-github/hooks/post-task-completion.sh.backup +0 -258
  171. package/plugins/specweave-jira/hooks/post-task-completion.sh.backup +0 -172
  172. package/plugins/specweave-release/hooks/.specweave/logs/dora-tracking.log +0 -444
  173. package/plugins/specweave-release/hooks/post-task-completion.sh.backup +0 -110
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "specweave",
3
3
  "description": "SpecWeave framework. Provides increment planning (PM, Architect, Tech Lead agents), specification generation, TDD workflow, living docs sync, and brownfield support. Essential for all SpecWeave projects.",
4
- "version": "0.24.0",
4
+ "version": "0.24.4",
5
5
  "author": {
6
6
  "name": "SpecWeave Team",
7
7
  "url": "https://spec-weave.com"
@@ -27,7 +27,7 @@
27
27
  {
28
28
  "type": "command",
29
29
  "command": "${CLAUDE_PLUGIN_ROOT}/hooks/pre-task-completion.sh",
30
- "timeout": 60
30
+ "timeout": 2
31
31
  }
32
32
  ]
33
33
  },
@@ -37,7 +37,7 @@
37
37
  {
38
38
  "type": "command",
39
39
  "command": "${CLAUDE_PLUGIN_ROOT}/hooks/pre-edit-spec.sh",
40
- "timeout": 2
40
+ "timeout": 1
41
41
  }
42
42
  ]
43
43
  },
@@ -47,7 +47,7 @@
47
47
  {
48
48
  "type": "command",
49
49
  "command": "${CLAUDE_PLUGIN_ROOT}/hooks/pre-write-spec.sh",
50
- "timeout": 2
50
+ "timeout": 1
51
51
  }
52
52
  ]
53
53
  }
@@ -842,6 +842,8 @@ Based on your answers, I'll calculate RICE scores and create a prioritized roadm
842
842
 
843
843
  **MANDATORY STEP**: After creating increment files, you MUST ACTUALLY EXECUTE metadata.json validation using Read and Write tools.
844
844
 
845
+ **NOTE (v0.24.5+)**: The `increment-planner` skill now has explicit Step 11 for metadata.json creation. This validation is a **safety net** if the skill is bypassed or if you're invoked directly via `/specweave:increment`.
846
+
845
847
  ### Why This Matters
846
848
 
847
849
  Without metadata.json:
@@ -40,53 +40,6 @@ You are helping the user implement a SpecWeave increment by executing tasks from
40
40
 
41
41
  ## Workflow
42
42
 
43
- ### Step 0: Plugin Validation (MANDATORY - ALWAYS FIRST! v0.9.4+)
44
-
45
- 🚨 **CRITICAL**: Before ANY task execution, validate SpecWeave plugin installation.
46
-
47
- **Why This Matters**:
48
- - Ensures SpecWeave marketplace is registered in Claude Code
49
- - Ensures core `specweave` plugin is installed
50
- - Prevents execution failures from missing dependencies
51
- - Enables seamless environment migration (local → VM → Cloud IDE)
52
-
53
- **Implementation**:
54
-
55
- Use the Bash tool to run:
56
- ```bash
57
- npx specweave validate-plugins --auto-install
58
- ```
59
-
60
- **Expected Output (Success)**:
61
- ```
62
- ✅ All plugins validated!
63
- • Core plugin: installed (v0.9.4)
64
- ```
65
-
66
- **Expected Output (Missing Components)**:
67
- ```
68
- ❌ Missing components detected:
69
- • SpecWeave marketplace not registered
70
- • Core plugin (specweave) not installed
71
-
72
- 📦 Installing missing components...
73
- ✅ Marketplace registered (.claude/settings.json)
74
- ✅ Core plugin installed (specweave)
75
-
76
- 🎉 Environment ready! Proceeding with task execution...
77
- ```
78
-
79
- **What to Do After Validation**:
80
-
81
- 1. ✅ **If validation passes**: Proceed to Step 1
82
- 2. ⚠️ **If validation fails with errors**: Show error messages and STOP (do NOT proceed)
83
- 3. 🔄 **If auto-install succeeded**: Proceed to Step 1
84
- 4. ⚠️ **If auto-install failed**: Show manual instructions and STOP
85
-
86
- **DO NOT PROCEED** to Step 1 until plugin validation passes!
87
-
88
- ---
89
-
90
43
  ### Step 1: Load Context
91
44
 
92
45
  1. **Find increment directory**:
@@ -11,88 +11,6 @@ You are helping the user create a new SpecWeave increment with automatic closure
11
11
 
12
12
  ## Steps:
13
13
 
14
- ### Step 0: Plugin Validation (MANDATORY - ALWAYS FIRST! v0.9.4+)
15
-
16
- 🚨 **CRITICAL**: Before ANY planning or execution, validate SpecWeave plugin installation.
17
-
18
- **Why This Matters**:
19
- - Ensures SpecWeave marketplace is registered in Claude Code
20
- - Ensures core `specweave` plugin is installed
21
- - Detects and suggests context-specific plugins based on your increment description
22
- - Prevents cryptic "command not found" errors
23
- - Enables seamless environment migration (local → VM → Cloud IDE)
24
-
25
- **Implementation**:
26
-
27
- Use the Bash tool to run:
28
- ```bash
29
- npx specweave validate-plugins --auto-install --context="$(cat <<'EOF'
30
- $USER_INCREMENT_DESCRIPTION
31
- EOF
32
- )"
33
- ```
34
-
35
- **Replace `$USER_INCREMENT_DESCRIPTION`** with the actual increment description provided by the user.
36
-
37
- **Expected Output (Success)**:
38
- ```
39
- ✅ All plugins validated!
40
- • Core plugin: installed (v0.9.4)
41
- • Context plugins: specweave-github (detected from "GitHub sync")
42
- ```
43
-
44
- **Expected Output (Missing Components)**:
45
- ```
46
- ❌ Missing components detected:
47
- • SpecWeave marketplace not registered
48
- • Core plugin (specweave) not installed
49
- • Context plugin (specweave-github) not installed
50
-
51
- 📦 Installing missing components...
52
- ✅ Marketplace registered (.claude/settings.json)
53
- ✅ Core plugin installed (specweave)
54
- ✅ Context plugin installed (specweave-github)
55
-
56
- 🎉 Environment ready! Proceeding with increment planning...
57
- ```
58
-
59
- **What to Do After Validation**:
60
-
61
- 1. ✅ **If validation passes**: Proceed to Step 0A
62
- 2. ⚠️ **If validation fails with errors**: Show error messages and STOP (do NOT proceed)
63
- 3. 🔄 **If auto-install succeeded**: Proceed to Step 0A
64
- 4. ⚠️ **If auto-install failed**: Show manual instructions (see below) and STOP
65
-
66
- **Manual Installation Instructions** (if auto-install fails):
67
- ```
68
- ❌ Auto-install failed. Please install manually:
69
-
70
- 1. Register SpecWeave marketplace:
71
- Edit ~/.claude/settings.json and add:
72
- {
73
- "extraKnownMarketplaces": {
74
- "specweave": {
75
- "source": {
76
- "source": "github",
77
- "repo": "anton-abyzov/specweave",
78
- "path": ".claude-plugin"
79
- }
80
- }
81
- }
82
- }
83
-
84
- 2. Install core plugin:
85
- Run: /plugin install specweave
86
-
87
- 3. Restart Claude Code
88
-
89
- 4. Re-run this command
90
- ```
91
-
92
- **DO NOT PROCEED** to Step 0A until plugin validation passes!
93
-
94
- ---
95
-
96
14
  ### Step 0A: STRICT Pre-Flight Check (MANDATORY - v0.6.0+)
97
15
 
98
16
  **⛔ THE IRON RULE: Cannot start increment N+1 until increment N is DONE**
@@ -32,53 +32,6 @@ The `/specweave:next` command is your **workflow continuation** command. It:
32
32
 
33
33
  ## Workflow
34
34
 
35
- ### Step 0: Plugin Validation (MANDATORY - ALWAYS FIRST! v0.9.4+)
36
-
37
- 🚨 **CRITICAL**: Before ANY workflow transition, validate SpecWeave plugin installation.
38
-
39
- **Why This Matters**:
40
- - Ensures SpecWeave marketplace is registered in Claude Code
41
- - Ensures core `specweave` plugin is installed
42
- - Prevents workflow interruptions from missing dependencies
43
- - Enables seamless environment migration (local → VM → Cloud IDE)
44
-
45
- **Implementation**:
46
-
47
- Use the Bash tool to run:
48
- ```bash
49
- npx specweave validate-plugins --auto-install
50
- ```
51
-
52
- **Expected Output (Success)**:
53
- ```
54
- ✅ All plugins validated!
55
- • Core plugin: installed (v0.9.4)
56
- ```
57
-
58
- **Expected Output (Missing Components)**:
59
- ```
60
- ❌ Missing components detected:
61
- • SpecWeave marketplace not registered
62
- • Core plugin (specweave) not installed
63
-
64
- 📦 Installing missing components...
65
- ✅ Marketplace registered (.claude/settings.json)
66
- ✅ Core plugin installed (specweave)
67
-
68
- 🎉 Environment ready! Proceeding with workflow transition...
69
- ```
70
-
71
- **What to Do After Validation**:
72
-
73
- 1. ✅ **If validation passes**: Proceed to Step 1
74
- 2. ⚠️ **If validation fails with errors**: Show error messages and STOP (do NOT proceed)
75
- 3. 🔄 **If auto-install succeeded**: Proceed to Step 1
76
- 4. ⚠️ **If auto-install failed**: Show manual instructions and STOP
77
-
78
- **DO NOT PROCEED** to Step 1 until plugin validation passes!
79
-
80
- ---
81
-
82
35
  ### Step 1: Find Active Increment
83
36
 
84
37
  ```bash
@@ -250,16 +250,48 @@ fi
250
250
  (
251
251
  set +e # Disable error propagation in background job
252
252
 
253
- # Detect current increment ONCE
254
- CURRENT_INCREMENT=$(ls -td .specweave/increments/*/ 2>/dev/null | xargs -n1 basename | grep -v "_backlog" | grep -v "_archive" | grep -v "_working" | head -1)
253
+ # ============================================================================
254
+ # CRITICAL FIX: Read active increments from state file (NOT time-based detection)
255
+ # ============================================================================
256
+ # WHY: The old logic used 'ls -td' which:
257
+ # 1. Could pick up completed increments if recently modified
258
+ # 2. Caused infinite loops on increments with bad AC data
259
+ # 3. Wasted resources syncing 50+ completed increments
260
+ #
261
+ # NEW: Only sync increments that are ACTIVELY being worked on
262
+ # Source of truth: .specweave/state/active-increment.json
263
+ # ============================================================================
264
+
265
+ ACTIVE_STATE_FILE=".specweave/state/active-increment.json"
266
+ ACTIVE_INCREMENTS=()
267
+
268
+ if [[ ! -f "$ACTIVE_STATE_FILE" ]]; then
269
+ echo "[$(date)] ⚠️ No active state file found, skipping all background work" >> "$DEBUG_LOG" 2>/dev/null || true
270
+ echo "0" > "$CIRCUIT_BREAKER_FILE" 2>/dev/null || true # Reset on success
271
+ exit 0
272
+ fi
273
+
274
+ if command -v jq >/dev/null 2>&1; then
275
+ # Use jq to parse the active increments array
276
+ # NOTE: mapfile requires bash 4+, macOS has bash 3.2, use while read instead
277
+ while IFS= read -r increment; do
278
+ ACTIVE_INCREMENTS+=("$increment")
279
+ done < <(jq -r '.ids[]' "$ACTIVE_STATE_FILE" 2>/dev/null)
280
+ else
281
+ # Fallback: simple grep parsing (less reliable, but works without jq)
282
+ # Match only increment IDs: 4 digits, dash, then letters/numbers/dashes
283
+ echo "[$(date)] ⚠️ jq not found, using fallback parsing" >> "$DEBUG_LOG" 2>/dev/null || true
284
+ ACTIVE_INCREMENTS=($(grep -o '"[0-9]\{4\}-[a-zA-Z0-9][a-zA-Z0-9_-]*"' "$ACTIVE_STATE_FILE" 2>/dev/null | tr -d '"'))
285
+ fi
255
286
 
256
- if [[ -z "$CURRENT_INCREMENT" ]]; then
257
- echo "[$(date)] No active increment, skipping all background work" >> "$DEBUG_LOG" 2>/dev/null || true
287
+ # If no active increments, skip all work
288
+ if [[ ${#ACTIVE_INCREMENTS[@]} -eq 0 ]]; then
289
+ echo "[$(date)] ✓ No active increments, skipping all background work (this is normal)" >> "$DEBUG_LOG" 2>/dev/null || true
258
290
  echo "0" > "$CIRCUIT_BREAKER_FILE" 2>/dev/null || true # Reset on success
259
291
  exit 0
260
292
  fi
261
293
 
262
- echo "[$(date)] Starting consolidated background work for $CURRENT_INCREMENT" >> "$DEBUG_LOG" 2>/dev/null || true
294
+ echo "[$(date)] 📋 Found ${#ACTIVE_INCREMENTS[@]} active increment(s): ${ACTIVE_INCREMENTS[*]}" >> "$DEBUG_LOG" 2>/dev/null || true
263
295
 
264
296
  # Only proceed if Node.js is available
265
297
  if ! command -v node &> /dev/null; then
@@ -271,6 +303,33 @@ fi
271
303
  # Track if ANY operation succeeded (for circuit breaker)
272
304
  ANY_SUCCESS=false
273
305
 
306
+ # ============================================================================
307
+ # PROCESS EACH ACTIVE INCREMENT
308
+ # ============================================================================
309
+ for CURRENT_INCREMENT in "${ACTIVE_INCREMENTS[@]}"; do
310
+ echo "[$(date)] 🔄 Processing increment: $CURRENT_INCREMENT" >> "$DEBUG_LOG" 2>/dev/null || true
311
+
312
+ # Safety check: Verify increment exists and is not archived
313
+ if [[ ! -d ".specweave/increments/$CURRENT_INCREMENT" ]]; then
314
+ echo "[$(date)] ⚠️ Increment $CURRENT_INCREMENT not found, skipping" >> "$DEBUG_LOG" 2>/dev/null || true
315
+ continue
316
+ fi
317
+
318
+ if [[ -d ".specweave/increments/_archive/$CURRENT_INCREMENT" ]]; then
319
+ echo "[$(date)] ⚠️ Increment $CURRENT_INCREMENT is archived, skipping" >> "$DEBUG_LOG" 2>/dev/null || true
320
+ continue
321
+ fi
322
+
323
+ # Additional safety: Check metadata status (skip completed/abandoned)
324
+ METADATA_FILE=".specweave/increments/$CURRENT_INCREMENT/metadata.json"
325
+ if [[ -f "$METADATA_FILE" ]] && command -v jq >/dev/null 2>&1; then
326
+ INCREMENT_STATUS=$(jq -r '.status // "active"' "$METADATA_FILE" 2>/dev/null || echo "active")
327
+ if [[ "$INCREMENT_STATUS" == "completed" ]] || [[ "$INCREMENT_STATUS" == "abandoned" ]]; then
328
+ echo "[$(date)] ⏭️ Skipping $CURRENT_INCREMENT (status: $INCREMENT_STATUS)" >> "$DEBUG_LOG" 2>/dev/null || true
329
+ continue
330
+ fi
331
+ fi
332
+
274
333
  # ============================================================================
275
334
  # 1. UPDATE TASKS.MD
276
335
  # ============================================================================
@@ -429,8 +488,10 @@ fi
429
488
  fi
430
489
  fi
431
490
 
491
+ done # End of ACTIVE_INCREMENTS loop
492
+
432
493
  # ============================================================================
433
- # 6. STATUS LINE UPDATE
494
+ # 6. STATUS LINE UPDATE (GLOBAL - outside loop)
434
495
  # ============================================================================
435
496
  echo "[$(date)] 📊 Updating status line" >> "$DEBUG_LOG" 2>/dev/null || true
436
497
 
@@ -101,6 +101,17 @@ else
101
101
  exit 0 # Let PostToolUse handle it with mtime fallback
102
102
  fi
103
103
 
104
+ # ============================================================================
105
+ # EARLY EXIT: Only process .specweave/ files (v0.24.4 Performance Fix)
106
+ # ============================================================================
107
+ # 90% of Edit operations are on non-SpecWeave files (src/, tests/, node_modules/)
108
+ # Exit immediately for non-.specweave/ files to reduce hook overhead by 90%
109
+
110
+ if [[ "$FILE_PATH" != *"/.specweave/"* ]]; then
111
+ echo "[$(date)] pre-edit-spec: Not a .specweave/ file, skipping (performance optimization)" >> "$DEBUG_LOG" 2>/dev/null || true
112
+ exit 0
113
+ fi
114
+
104
115
  # Check if this is a spec.md or tasks.md file in increments folder
105
116
  IS_SPEC_FILE=false
106
117
  if [[ "$FILE_PATH" == *"/spec.md" ]] || [[ "$FILE_PATH" == *"/tasks.md" ]]; then
@@ -44,14 +44,74 @@ PROJECT_ROOT="$(find_project_root "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
44
44
  cd "$PROJECT_ROOT" 2>/dev/null || true
45
45
 
46
46
  # ============================================================================
47
- # CONFIGURATION
47
+ # EMERGENCY SAFETY CHECKS (v0.24.4 - Performance Fix)
48
48
  # ============================================================================
49
49
 
50
50
  LOGS_DIR=".specweave/logs"
51
51
  DEBUG_LOG="$LOGS_DIR/hooks-debug.log"
52
-
53
52
  mkdir -p "$LOGS_DIR" 2>/dev/null || true
54
53
 
54
+ # CIRCUIT BREAKER: Auto-disable after consecutive failures
55
+ CIRCUIT_BREAKER_FILE=".specweave/state/.hook-circuit-breaker-pre"
56
+ CIRCUIT_BREAKER_THRESHOLD=3
57
+
58
+ mkdir -p ".specweave/state" 2>/dev/null || true
59
+
60
+ if [[ -f "$CIRCUIT_BREAKER_FILE" ]]; then
61
+ FAILURE_COUNT=$(cat "$CIRCUIT_BREAKER_FILE" 2>/dev/null || echo 0)
62
+ if (( FAILURE_COUNT >= CIRCUIT_BREAKER_THRESHOLD )); then
63
+ # Circuit breaker is OPEN - hooks are disabled
64
+ exit 0
65
+ fi
66
+ fi
67
+
68
+ # FILE LOCK: Only allow 1 pre-task-completion hook at a time
69
+ LOCK_FILE=".specweave/state/.hook-pre-task.lock"
70
+ LOCK_TIMEOUT=5 # seconds (shorter than PostToolUse)
71
+
72
+ LOCK_ACQUIRED=false
73
+ for i in {1..5}; do
74
+ if mkdir "$LOCK_FILE" 2>/dev/null; then
75
+ LOCK_ACQUIRED=true
76
+ trap 'rmdir "$LOCK_FILE" 2>/dev/null || true' EXIT
77
+ break
78
+ fi
79
+
80
+ # Check for stale lock
81
+ if [[ -d "$LOCK_FILE" ]]; then
82
+ LOCK_AGE=$(($(date +%s) - $(stat -f "%m" "$LOCK_FILE" 2>/dev/null || echo 0)))
83
+ if (( LOCK_AGE > LOCK_TIMEOUT )); then
84
+ rmdir "$LOCK_FILE" 2>/dev/null || true
85
+ continue
86
+ fi
87
+ fi
88
+
89
+ sleep 0.1
90
+ done
91
+
92
+ if [[ "$LOCK_ACQUIRED" == "false" ]]; then
93
+ # Another instance is running, skip
94
+ exit 0
95
+ fi
96
+
97
+ # DEBOUNCING: Prevent duplicate hook fires
98
+ LAST_FIRE_FILE="$LOGS_DIR/last-pre-hook-fire"
99
+ DEBOUNCE_SECONDS=5 # Same as PostToolUse
100
+
101
+ CURRENT_TIME=$(date +%s)
102
+
103
+ if [ -f "$LAST_FIRE_FILE" ]; then
104
+ LAST_FIRE=$(cat "$LAST_FIRE_FILE" 2>/dev/null || echo "0")
105
+ TIME_DIFF=$((CURRENT_TIME - LAST_FIRE))
106
+
107
+ if [ "$TIME_DIFF" -lt "$DEBOUNCE_SECONDS" ]; then
108
+ # Debounced - skip this execution
109
+ exit 0
110
+ fi
111
+ fi
112
+
113
+ echo "$CURRENT_TIME" > "$LAST_FIRE_FILE"
114
+
55
115
  echo "[$(date)] 🔒 Pre-task-completion hook fired" >> "$DEBUG_LOG" 2>/dev/null || true
56
116
 
57
117
  # ============================================================================
@@ -170,6 +230,9 @@ if [ "$VALIDATION_EXIT_CODE" = "0" ]; then
170
230
  # Validation passed - allow completion
171
231
  echo "[$(date)] ✅ AC test validation passed" >> "$DEBUG_LOG" 2>/dev/null || true
172
232
 
233
+ # Reset circuit breaker on success
234
+ echo "0" > "$CIRCUIT_BREAKER_FILE" 2>/dev/null || true
235
+
173
236
  VALIDATION_SUMMARY=$(cat "$VALIDATION_OUTPUT" | tail -5 | tr '\n' ' ')
174
237
 
175
238
  rm -f "$VALIDATION_OUTPUT"
@@ -184,6 +247,10 @@ else
184
247
  # Validation failed - block completion
185
248
  echo "[$(date)] ❌ AC test validation failed" >> "$DEBUG_LOG" 2>/dev/null || true
186
249
 
250
+ # Increment circuit breaker on failure
251
+ CURRENT_FAILURES=$(cat "$CIRCUIT_BREAKER_FILE" 2>/dev/null || echo 0)
252
+ echo "$((CURRENT_FAILURES + 1))" > "$CIRCUIT_BREAKER_FILE" 2>/dev/null || true
253
+
187
254
  VALIDATION_ERROR=$(cat "$VALIDATION_OUTPUT" | grep -A 10 "VALIDATION FAILED" | tr '\n' ' ' | cut -c 1-300)
188
255
 
189
256
  rm -f "$VALIDATION_OUTPUT"
@@ -101,6 +101,17 @@ else
101
101
  exit 0 # Let PostToolUse handle it with mtime fallback
102
102
  fi
103
103
 
104
+ # ============================================================================
105
+ # EARLY EXIT: Only process .specweave/ files (v0.24.4 Performance Fix)
106
+ # ============================================================================
107
+ # 90% of Write operations are on non-SpecWeave files (src/, tests/, node_modules/)
108
+ # Exit immediately for non-.specweave/ files to reduce hook overhead by 90%
109
+
110
+ if [[ "$FILE_PATH" != *"/.specweave/"* ]]; then
111
+ echo "[$(date)] pre-write-spec: Not a .specweave/ file, skipping (performance optimization)" >> "$DEBUG_LOG" 2>/dev/null || true
112
+ exit 0
113
+ fi
114
+
104
115
  # Check if this is a spec.md or tasks.md file in increments folder
105
116
  IS_SPEC_FILE=false
106
117
  if [[ "$FILE_PATH" == *"/spec.md" ]] || [[ "$FILE_PATH" == *"/tasks.md" ]]; then
@@ -28,13 +28,14 @@ This skill creates comprehensive, well-structured implementation plans for SpecW
28
28
  The increment-planner skill automates the creation of implementation plans for ANY type of work:
29
29
  - Auto-numbered increment directories (`0001-9999` 4-digit format)
30
30
  - Duplicate detection (prevents creating 0002 when 0002 already exists)
31
- - Complete increment artifacts (spec.md, plan.md, tasks.md with embedded tests)
31
+ - Complete increment artifacts (spec.md, plan.md, tasks.md with embedded tests, **metadata.json**)
32
32
  - Proper context manifests for selective loading
33
33
  - Constitutional compliance
34
34
  - Separation of WHAT/WHY (spec) from HOW (plan) from STEPS (tasks with test plans)
35
35
  - **v0.7.0+**: Test-Aware Planning (bidirectional AC↔Task↔Test linking)
36
36
  - **v0.8.0+**: Multi-Project Support (specs organized by project/team)
37
37
  - **v0.18.0+**: Bidirectional Task↔User Story Linking (automatic during `/specweave:done`)
38
+ - **v0.24.5+**: **MANDATORY metadata.json creation** (enables status tracking, WIP limits, external tool sync)
38
39
 
39
40
  ## Bidirectional Linking (v0.18.0+)
40
41
 
@@ -593,11 +594,18 @@ Generate the complete feature directory with all required files:
593
594
  ├── spec.md # Feature specification (WHAT and WHY)
594
595
  ├── plan.md # Implementation plan (HOW)
595
596
  ├── tasks.md # Executable tasks (STEPS) with embedded test plans (v0.7.0+)
597
+ ├── metadata.json # Increment metadata (MANDATORY - v0.24.5+)
596
598
  └── context-manifest.yaml # Context loading specification
597
599
  ```
598
600
 
599
601
  **v0.7.0 Change**: tests.md eliminated - tests are now embedded in each task in tasks.md
600
602
 
603
+ **⚠️ CRITICAL (v0.24.5+)**: `metadata.json` is **MANDATORY** regardless of invocation method (natural language prompt or `/specweave:increment`). Without it:
604
+ - ❌ Status line shows nothing (no active increment tracking)
605
+ - ❌ WIP limits don't work (can't count active increments)
606
+ - ❌ External sync breaks (no GitHub/JIRA/ADO links)
607
+ - ❌ All increment management commands fail (`/status`, `/pause`, `/resume`, `/done`)
608
+
601
609
  ### Step 5: Generate spec.md
602
610
 
603
611
  **Purpose**: Define WHAT this feature does and WHY it's needed.
@@ -1060,7 +1068,89 @@ tags:
1060
1068
  - Token budget to prevent bloat
1061
1069
  - Related features for dependency tracking
1062
1070
 
1063
- ### Step 10: Validate and Finalize
1071
+ ### Step 11: Generate metadata.json (⚠️ MANDATORY - v0.24.5+)
1072
+
1073
+ **Purpose**: Create increment metadata for status tracking, WIP limits, and external tool sync.
1074
+
1075
+ **CRITICAL**: This step is **NON-NEGOTIABLE** regardless of how the increment was created (natural language prompt, `/specweave:increment`, or any other method).
1076
+
1077
+ **Execution Workflow (MUST USE TOOLS)**:
1078
+
1079
+ **STEP 1: Check if metadata.json exists**
1080
+ ```
1081
+ Use Read tool:
1082
+ file_path: .specweave/increments/{incrementId}/metadata.json
1083
+ ```
1084
+
1085
+ **STEP 2: If missing (file not found), create it immediately**
1086
+ ```
1087
+ Use Write tool:
1088
+ file_path: .specweave/increments/{incrementId}/metadata.json
1089
+ content: {
1090
+ "id": "{incrementId}",
1091
+ "status": "planned",
1092
+ "type": "{type}",
1093
+ "priority": "{priority}",
1094
+ "created": "{ISO-8601-timestamp}",
1095
+ "lastActivity": "{ISO-8601-timestamp}",
1096
+ "testMode": "TDD",
1097
+ "coverageTarget": 95,
1098
+ "feature_id": null,
1099
+ "epic_id": null,
1100
+ "externalLinks": {}
1101
+ }
1102
+ ```
1103
+
1104
+ **Field Extraction (from spec.md frontmatter)**:
1105
+ - `id`: Increment directory name (e.g., "0001-user-authentication")
1106
+ - `type`: Extract from `type:` in spec.md frontmatter OR default to "feature"
1107
+ - `priority`: Extract from `priority:` in spec.md frontmatter OR default to "P1"
1108
+ - `created`/`lastActivity`: Current timestamp in ISO-8601 format (e.g., "2025-11-22T19:30:00Z")
1109
+ - `testMode`: Extract from `test_mode:` in spec.md frontmatter OR default to "TDD"
1110
+ - `coverageTarget`: Extract from `coverage_target:` in spec.md frontmatter OR default to 95
1111
+
1112
+ **STEP 3: Validate creation succeeded**
1113
+ ```
1114
+ Use Read tool again:
1115
+ file_path: .specweave/increments/{incrementId}/metadata.json
1116
+ ```
1117
+
1118
+ If Read succeeds, output:
1119
+ ```
1120
+ ✅ metadata.json created successfully
1121
+ Status: planned
1122
+ Type: {type}
1123
+ Ready for /specweave:do
1124
+ ```
1125
+
1126
+ **Why This Cannot Be Skipped**:
1127
+ Without metadata.json, the increment is **effectively broken**:
1128
+ - Status line won't show it as active
1129
+ - WIP limit enforcement fails (infinite increments possible!)
1130
+ - All increment commands fail (`/status`, `/pause`, `/resume`, `/done`)
1131
+ - External tool sync (GitHub/JIRA/ADO) completely broken
1132
+ - Hooks can't detect the increment
1133
+
1134
+ **Example metadata.json**:
1135
+ ```json
1136
+ {
1137
+ "id": "0001-user-authentication",
1138
+ "status": "planned",
1139
+ "type": "feature",
1140
+ "priority": "P1",
1141
+ "created": "2025-11-22T19:30:00Z",
1142
+ "lastActivity": "2025-11-22T19:30:00Z",
1143
+ "testMode": "TDD",
1144
+ "coverageTarget": 95,
1145
+ "feature_id": null,
1146
+ "epic_id": null,
1147
+ "externalLinks": {}
1148
+ }
1149
+ ```
1150
+
1151
+ **⚠️ ENFORCEMENT**: If you complete increment creation without creating metadata.json, you have **failed the task**. This is not optional.
1152
+
1153
+ ### Step 12: Validate and Finalize
1064
1154
 
1065
1155
  Before completing:
1066
1156
 
@@ -1074,6 +1164,7 @@ Before completing:
1074
1164
  - plan.md has sufficient technical detail + test strategy
1075
1165
  - tasks.md has exact file paths + embedded test plans (BDD format)
1076
1166
  - tasks.md covers all P1 AC-IDs with test cases
1167
+ - **metadata.json exists and is valid** (v0.24.5+ MANDATORY)
1077
1168
  - context-manifest.yaml is precise
1078
1169
 
1079
1170
  3. **Update Features Index**:
@@ -1260,11 +1351,39 @@ max_context_tokens: 8000
1260
1351
  priority: high
1261
1352
  ```
1262
1353
 
1263
- **Step 10**: Validate
1354
+ **Step 10**: Generate metadata.json (⚠️ MANDATORY v0.24.5+)
1355
+ ```typescript
1356
+ // Use Read tool to check if exists
1357
+ Read({ file_path: ".specweave/increments/0003-stripe-payment-integration/metadata.json" });
1358
+
1359
+ // If missing, use Write tool to create
1360
+ Write({
1361
+ file_path: ".specweave/increments/0003-stripe-payment-integration/metadata.json",
1362
+ content: JSON.stringify({
1363
+ "id": "0003-stripe-payment-integration",
1364
+ "status": "planned",
1365
+ "type": "feature",
1366
+ "priority": "P1",
1367
+ "created": "2025-11-22T19:30:00Z",
1368
+ "lastActivity": "2025-11-22T19:30:00Z",
1369
+ "testMode": "TDD",
1370
+ "coverageTarget": 95,
1371
+ "feature_id": null,
1372
+ "epic_id": null,
1373
+ "externalLinks": {}
1374
+ }, null, 2)
1375
+ });
1376
+
1377
+ // Validate creation succeeded
1378
+ Read({ file_path: ".specweave/increments/0003-stripe-payment-integration/metadata.json" });
1379
+ ```
1380
+
1381
+ **Step 11**: Validate
1264
1382
  - ✅ spec.md is technology-agnostic with AC-IDs
1265
1383
  - ✅ plan.md documents Stripe SDK choice + test strategy
1266
1384
  - ✅ tasks.md has embedded test plans (BDD format)
1267
1385
  - ✅ tasks.md covers all P1 AC-IDs with tests
1386
+ - ✅ **metadata.json exists and is valid** (v0.24.5+ MANDATORY)
1268
1387
  - ✅ Constitutional compliance verified
1269
1388
 
1270
1389
  **Output**:
@@ -1276,12 +1395,13 @@ Files created:
1276
1395
  - spec.md (12 user stories, 34 AC-IDs)
1277
1396
  - plan.md (5 phases, architecture diagrams, test strategy)
1278
1397
  - tasks.md (23 tasks with embedded tests, 85% coverage target)
1398
+ - metadata.json ✅ (status: planned, type: feature)
1279
1399
  - context-manifest.yaml
1280
1400
 
1281
1401
  Next steps:
1282
1402
  1. Review spec.md - verify user stories and acceptance criteria
1283
1403
  2. Approve plan.md - validate technical approach
1284
- 3. Start implementation: specweave implement 0003
1404
+ 3. Start implementation: /specweave:do 0003
1285
1405
  ```
1286
1406
 
1287
1407
  ## Helper Scripts
@@ -373,7 +373,6 @@ ${userStory.technicalContext}
373
373
  return mapping.task || "Task";
374
374
  case "Subtask":
375
375
  return mapping.task || "Task";
376
- // ADO doesn't have subtasks, use Task
377
376
  default:
378
377
  return "User Story";
379
378
  }