specweave 0.26.3 → 0.26.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CLAUDE.md +261 -1382
- package/dist/src/cli/commands/plan/plan-orchestrator.js +2 -2
- package/dist/src/cli/commands/plan/plan-orchestrator.js.map +1 -1
- package/dist/src/cli/helpers/issue-tracker/github-multi-repo.d.ts.map +1 -1
- package/dist/src/cli/helpers/issue-tracker/github-multi-repo.js +147 -55
- package/dist/src/cli/helpers/issue-tracker/github-multi-repo.js.map +1 -1
- package/dist/src/config/types.d.ts +203 -1208
- package/dist/src/config/types.d.ts.map +1 -1
- package/dist/src/core/increment/completion-validator.d.ts +4 -0
- package/dist/src/core/increment/completion-validator.d.ts.map +1 -1
- package/dist/src/core/increment/completion-validator.js +36 -0
- package/dist/src/core/increment/completion-validator.js.map +1 -1
- package/dist/src/core/increment/increment-reopener.d.ts.map +1 -1
- package/dist/src/core/increment/increment-reopener.js +13 -14
- package/dist/src/core/increment/increment-reopener.js.map +1 -1
- package/dist/src/core/increment/metadata-manager.d.ts.map +1 -1
- package/dist/src/core/increment/metadata-manager.js +16 -0
- package/dist/src/core/increment/metadata-manager.js.map +1 -1
- package/dist/src/core/increment/status-change-sync-trigger.d.ts +85 -0
- package/dist/src/core/increment/status-change-sync-trigger.d.ts.map +1 -0
- package/dist/src/core/increment/status-change-sync-trigger.js +137 -0
- package/dist/src/core/increment/status-change-sync-trigger.js.map +1 -0
- package/dist/src/core/increment/sync-circuit-breaker.d.ts +64 -0
- package/dist/src/core/increment/sync-circuit-breaker.d.ts.map +1 -0
- package/dist/src/core/increment/sync-circuit-breaker.js +95 -0
- package/dist/src/core/increment/sync-circuit-breaker.js.map +1 -0
- package/dist/src/core/living-docs/living-docs-sync.d.ts +12 -0
- package/dist/src/core/living-docs/living-docs-sync.d.ts.map +1 -1
- package/dist/src/core/living-docs/living-docs-sync.js +161 -31
- package/dist/src/core/living-docs/living-docs-sync.js.map +1 -1
- package/dist/src/core/us-sync-throttle.d.ts +113 -0
- package/dist/src/core/us-sync-throttle.d.ts.map +1 -0
- package/dist/src/core/us-sync-throttle.js +195 -0
- package/dist/src/core/us-sync-throttle.js.map +1 -0
- package/dist/src/init/architecture/types.d.ts +33 -140
- package/dist/src/init/architecture/types.d.ts.map +1 -1
- package/dist/src/init/compliance/types.d.ts +30 -27
- package/dist/src/init/compliance/types.d.ts.map +1 -1
- package/dist/src/init/repo/types.d.ts +11 -34
- package/dist/src/init/repo/types.d.ts.map +1 -1
- package/dist/src/init/research/src/config/types.d.ts +15 -82
- package/dist/src/init/research/src/config/types.d.ts.map +1 -1
- package/dist/src/init/research/types.d.ts +38 -93
- package/dist/src/init/research/types.d.ts.map +1 -1
- package/dist/src/init/team/types.d.ts +4 -42
- package/dist/src/init/team/types.d.ts.map +1 -1
- package/dist/src/utils/external-tool-drift-detector.d.ts +76 -0
- package/dist/src/utils/external-tool-drift-detector.d.ts.map +1 -0
- package/dist/src/utils/external-tool-drift-detector.js +235 -0
- package/dist/src/utils/external-tool-drift-detector.js.map +1 -0
- package/package.json +5 -5
- package/plugins/specweave/hooks/post-task-completion.sh +6 -6
- package/plugins/specweave/hooks/pre-increment-start.sh +6 -1
- package/plugins/specweave/lib/hooks/us-completion-orchestrator.js +62 -89
- package/plugins/specweave/lib/hooks/us-completion-orchestrator.ts +215 -0
- package/plugins/specweave/lib/vendor/core/increment/metadata-manager.js +16 -0
- package/plugins/specweave/lib/vendor/core/increment/metadata-manager.js.map +1 -1
- package/plugins/specweave/skills/brownfield-analyzer/SKILL.md +267 -868
- package/plugins/specweave/skills/increment-planner/SKILL.md +337 -1253
- package/plugins/specweave/skills/role-orchestrator/SKILL.md +293 -969
- package/plugins/specweave-docs/skills/technical-writing/SKILL.md +333 -839
- package/plugins/specweave-release/hooks/post-task-completion.sh +5 -1
- package/plugins/specweave-testing/skills/tdd-expert/SKILL.md +269 -749
- package/plugins/specweave-testing/skills/unit-testing-expert/SKILL.md +318 -810
package/CLAUDE.md
CHANGED
|
@@ -14,540 +14,168 @@ For **contributors to SpecWeave itself** (not users).
|
|
|
14
14
|
|
|
15
15
|
**NEVER run commands you know will fail.** Act on reasoning BEFORE execution.
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
- File ops before directory creation
|
|
21
|
-
|
|
22
|
-
```typescript
|
|
23
|
-
// ❌ WRONG: Attempt → Fail → Fix
|
|
24
|
-
node -e "require('./dist/file.js')" // You knew this would fail!
|
|
25
|
-
npm run rebuild
|
|
26
|
-
|
|
27
|
-
// ✅ CORRECT: Fix → Attempt
|
|
28
|
-
npm run rebuild
|
|
29
|
-
node -e "require('./dist/file.js')"
|
|
17
|
+
```bash
|
|
18
|
+
# ❌ WRONG: node -e "require('./dist/file.js')" (before build)
|
|
19
|
+
# ✅ CORRECT: npm run rebuild && node -e "require('./dist/file.js')"
|
|
30
20
|
```
|
|
31
21
|
|
|
32
22
|
---
|
|
33
23
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
**Standard Workflow** (Cross-platform):
|
|
24
|
+
## 1. Development Setup
|
|
37
25
|
|
|
26
|
+
**Standard Workflow**:
|
|
38
27
|
```bash
|
|
39
|
-
# Setup
|
|
40
28
|
git clone https://github.com/YOUR_USERNAME/specweave.git
|
|
41
29
|
cd specweave && npm install && npm run rebuild
|
|
42
30
|
|
|
43
31
|
# Development Cycle
|
|
44
|
-
vim src/core/task-parser.ts
|
|
45
32
|
npm run rebuild && npm test
|
|
46
|
-
git add . && git commit -m "feat: feature"
|
|
47
|
-
git push origin develop
|
|
33
|
+
git add . && git commit -m "feat: feature" && git push origin develop
|
|
48
34
|
# Wait 5-10s → Claude Code auto-updates marketplace
|
|
49
35
|
```
|
|
50
36
|
|
|
51
|
-
**Testing Unpushed
|
|
52
|
-
- **Option 1**: Temp branch → push → test → delete
|
|
53
|
-
- **Option 2**: Fork-based (`claude plugin marketplace add github:YOUR_USERNAME/specweave`)
|
|
37
|
+
**Testing Unpushed**: Temp branch → push → test → delete, OR `claude plugin marketplace add github:YOUR_USERNAME/specweave`
|
|
54
38
|
|
|
55
39
|
---
|
|
56
40
|
|
|
57
|
-
### 1a.
|
|
58
|
-
|
|
59
|
-
**Problem**: After implementing new plugins locally, Claude Code needs to reload the marketplace.
|
|
60
|
-
|
|
61
|
-
**Solution**: Use the automated refresh script!
|
|
41
|
+
### 1a. Marketplace Refresh
|
|
62
42
|
|
|
63
43
|
```bash
|
|
64
|
-
#
|
|
65
|
-
bash scripts/refresh-marketplace.sh
|
|
66
|
-
|
|
67
|
-
# LOCAL DEVELOPMENT - Uses your local changes (ONLY for active development!)
|
|
68
|
-
bash scripts/refresh-marketplace.sh --local
|
|
44
|
+
bash scripts/refresh-marketplace.sh # GitHub (default, ALWAYS use)
|
|
45
|
+
bash scripts/refresh-marketplace.sh --local # Local dev only (filesystem coupling risks)
|
|
69
46
|
```
|
|
70
47
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
**Why GitHub mode is mandatory:**
|
|
74
|
-
- ✅ **Separate Installation**: Creates proper copy at `~/.claude/plugins/marketplaces/specweave/`
|
|
75
|
-
- ✅ **Stable Source**: Pulls from committed GitHub code, not unstable local changes
|
|
76
|
-
- ✅ **No Path Coupling**: Clear separation between source and runtime
|
|
77
|
-
- ✅ **Production-Ready**: What end users will experience
|
|
78
|
-
|
|
79
|
-
**Why local mode is dangerous:**
|
|
80
|
-
- ❌ **Filesystem Coupling**: `installLocation` = source directory (no separate copy!)
|
|
81
|
-
- ❌ **Stale Hook Risk**: Any git operations, file deletions, or uncommitted changes affect "installed" plugins
|
|
82
|
-
- ❌ **Path Confusion**: Claude Code expects hooks at `~/.claude/plugins/marketplaces/` but they're in your working directory
|
|
83
|
-
- ❌ **Instability**: Leads to "hook not found" errors like you just experienced
|
|
84
|
-
|
|
85
|
-
**Rule of thumb:**
|
|
86
|
-
- **Development workflow**: Commit → Push → `bash scripts/refresh-marketplace.sh` (GitHub mode) → Test
|
|
87
|
-
- **Emergency local testing**: Use `--local` ONLY when you need to test uncommitted changes, then immediately switch back to GitHub mode
|
|
88
|
-
|
|
89
|
-
**What it does**:
|
|
90
|
-
1. ✅ Removes existing marketplace
|
|
91
|
-
2. ✅ Clears all plugin caches
|
|
92
|
-
3. ✅ Re-adds marketplace (local or GitHub)
|
|
93
|
-
4. ✅ Installs ALL plugins automatically
|
|
94
|
-
5. ✅ Shows success/failure summary
|
|
95
|
-
|
|
96
|
-
**Output Example**:
|
|
97
|
-
```
|
|
98
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
99
|
-
SpecWeave Marketplace Refresh (github mode)
|
|
100
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
48
|
+
**Use GitHub mode**: Proper install path, stable source, no hook coupling (~30s)
|
|
49
|
+
**Verify**: `jq -r '.specweave.source' ~/.claude/plugins/known_marketplaces.json` → should be `"github"`
|
|
101
50
|
|
|
102
|
-
|
|
103
|
-
✓ Marketplace removed
|
|
104
|
-
|
|
105
|
-
🧹 Step 2: Clearing plugin caches...
|
|
106
|
-
✓ Installed plugins cache backed up
|
|
107
|
-
|
|
108
|
-
📥 Step 3: Adding marketplace...
|
|
109
|
-
Pulling latest from GitHub: anton-abyzov/specweave
|
|
110
|
-
Cloning via SSH: git@github.com:anton-abyzov/specweave.git
|
|
111
|
-
✓ GitHub marketplace added
|
|
112
|
-
|
|
113
|
-
📋 Step 4: Reading plugin list...
|
|
114
|
-
✓ Found 27 plugins
|
|
115
|
-
|
|
116
|
-
⚙️ Step 5: Installing all plugins...
|
|
117
|
-
Installing specweave...
|
|
118
|
-
✓ specweave installed
|
|
119
|
-
|
|
120
|
-
[... all 19 plugins ...]
|
|
121
|
-
|
|
122
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
123
|
-
Installation Summary
|
|
124
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
125
|
-
|
|
126
|
-
Total plugins: 19
|
|
127
|
-
Successful: 19
|
|
128
|
-
Failed: 0
|
|
129
|
-
|
|
130
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
131
|
-
✓ ALL PLUGINS INSTALLED SUCCESSFULLY!
|
|
132
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
133
|
-
|
|
134
|
-
Next steps:
|
|
135
|
-
1. Restart Claude Code for changes to take effect
|
|
136
|
-
2. Run /plugin to verify all plugins loaded
|
|
137
|
-
3. Check ~/.claude/plugins/installed_plugins.json
|
|
138
|
-
```
|
|
139
|
-
|
|
140
|
-
**When to use**:
|
|
141
|
-
- ✅ After pushing changes to GitHub (GitHub mode - default)
|
|
142
|
-
- ✅ After pulling latest from GitHub (GitHub mode)
|
|
143
|
-
- ✅ When plugins aren't loading correctly (GitHub mode)
|
|
144
|
-
- ✅ After adding new plugins (commit → push → refresh with GitHub mode)
|
|
145
|
-
- ⚠️ To test uncommitted local changes (local mode - use sparingly!)
|
|
146
|
-
|
|
147
|
-
**Time**: ~30 seconds (vs 5-10 minutes manual)
|
|
148
|
-
|
|
149
|
-
**Verification after refresh**:
|
|
150
|
-
```bash
|
|
151
|
-
# Check marketplace source (should be "github")
|
|
152
|
-
cat ~/.claude/plugins/known_marketplaces.json | jq -r '.specweave.source'
|
|
153
|
-
|
|
154
|
-
# Should output: {"source": "github", "repo": "anton-abyzov/specweave"}
|
|
155
|
-
# NOT: {"source": "directory", "path": "/Users/..."}
|
|
156
|
-
```
|
|
157
|
-
|
|
158
|
-
**Requirements**: `jq` installed (`brew install jq`)
|
|
51
|
+
**Note**: GitHub mode shows "AC test validator not available" warning because `dist/` is gitignored. Use `--local` mode when developing hooks/validators to test with built artifacts. Regular users with `npm install specweave` won't see this (validator found in `node_modules/`).
|
|
159
52
|
|
|
160
53
|
---
|
|
161
54
|
|
|
162
|
-
### 1b. NPM Release
|
|
163
|
-
|
|
164
|
-
**Two release modes**: Default (GitHub Actions) and Direct (`--only` flag)
|
|
165
|
-
|
|
166
|
-
#### Default Mode (Recommended)
|
|
55
|
+
### 1b. NPM Release
|
|
167
56
|
|
|
168
57
|
```bash
|
|
169
|
-
#
|
|
170
|
-
/specweave-release:npm
|
|
171
|
-
```
|
|
172
|
-
|
|
173
|
-
**What happens**:
|
|
174
|
-
1. ✅ Bumps patch version (e.g., 0.24.11 → 0.24.12)
|
|
175
|
-
2. ✅ Creates git commit + tag
|
|
176
|
-
3. ✅ Pushes to GitHub
|
|
177
|
-
4. ✅ Triggers GitHub Actions workflow
|
|
178
|
-
5. ✅ GitHub Actions publishes to npm (1-2 min)
|
|
179
|
-
|
|
180
|
-
**Use when**: Regular releases, want CI validation
|
|
181
|
-
|
|
182
|
-
#### Direct Mode (`--only` flag)
|
|
183
|
-
|
|
184
|
-
```bash
|
|
185
|
-
# Publish directly to npm (bypasses GitHub Actions)
|
|
186
|
-
/specweave-release:npm --only
|
|
187
|
-
```
|
|
188
|
-
|
|
189
|
-
**What happens**:
|
|
190
|
-
1. ✅ Bumps patch version
|
|
191
|
-
2. ✅ Creates git commit + tag
|
|
192
|
-
3. ✅ Builds package (`npm run rebuild`)
|
|
193
|
-
4. ✅ **Publishes to npm immediately**
|
|
194
|
-
5. ✅ Pushes git changes to GitHub (optional)
|
|
195
|
-
|
|
196
|
-
**Use when**:
|
|
197
|
-
- 🔥 Emergency releases (hotfix needed NOW)
|
|
198
|
-
- ⚡ Want immediate feedback (no CI wait)
|
|
199
|
-
- 🧪 Testing release process locally
|
|
200
|
-
- 💻 GitHub Actions unavailable
|
|
201
|
-
|
|
202
|
-
**Example output**:
|
|
203
|
-
```
|
|
204
|
-
✅ Published directly to npm!
|
|
205
|
-
|
|
206
|
-
📦 Version: v0.24.12
|
|
207
|
-
🔗 NPM: https://www.npmjs.com/package/specweave
|
|
208
|
-
🏷️ Git Tag: v0.24.12 (created locally)
|
|
209
|
-
|
|
210
|
-
What happened:
|
|
211
|
-
- ✅ Version bumped and committed
|
|
212
|
-
- ✅ Git tag created locally
|
|
213
|
-
- ✅ Package built (npm run rebuild)
|
|
214
|
-
- ✅ Published to npm directly
|
|
215
|
-
- ✅ Git changes pushed to GitHub
|
|
216
|
-
|
|
217
|
-
Note: Published via direct push (bypassed GitHub Actions)
|
|
58
|
+
/specweave-release:npm # GitHub Actions (2-3 min, recommended)
|
|
59
|
+
/specweave-release:npm --only # Direct publish (30s, emergencies)
|
|
218
60
|
```
|
|
219
61
|
|
|
220
|
-
**Safety**:
|
|
221
|
-
- ✅ Both modes do pre-flight checks (branch, uncommitted changes)
|
|
222
|
-
- ✅ Both create proper git commits/tags
|
|
223
|
-
- ✅ Direct mode rebuilds before publishing
|
|
224
|
-
- ✅ Default mode is preferred for regular releases
|
|
225
|
-
|
|
226
|
-
**Time comparison**:
|
|
227
|
-
- Default mode: 2-3 minutes (includes CI)
|
|
228
|
-
- Direct mode (`--only`): 30 seconds
|
|
229
|
-
|
|
230
62
|
---
|
|
231
63
|
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
**CRITICAL RULES**:
|
|
64
|
+
## 2. Folder Structure Rules
|
|
235
65
|
|
|
236
|
-
**At `.specweave/increments/` root - ONLY
|
|
237
|
-
1.
|
|
238
|
-
2.
|
|
239
|
-
3. README.md (optional
|
|
240
|
-
|
|
241
|
-
**❌ NOT ALLOWED at root**: `_working/`, `reports/`, `logs/`, `scripts/`, or ANY other folders/files
|
|
242
|
-
|
|
243
|
-
**Inside each increment folder - ONLY 4 files at root**: `spec.md`, `plan.md`, `tasks.md`, `metadata.json`
|
|
66
|
+
**At `.specweave/increments/` root - ONLY**:
|
|
67
|
+
1. `####-increment-name/` folders
|
|
68
|
+
2. `_archive/` folder
|
|
69
|
+
3. `README.md` (optional)
|
|
244
70
|
|
|
71
|
+
**Inside increment folders - ONLY at root**: `spec.md`, `plan.md`, `tasks.md`, `metadata.json`
|
|
245
72
|
**Everything else → subfolders**: `reports/`, `scripts/`, `logs/`
|
|
246
73
|
|
|
247
74
|
```bash
|
|
248
|
-
#
|
|
249
|
-
# ❌ WRONG: .specweave/increments/reports/
|
|
250
|
-
# ❌ WRONG: .specweave/increments/0046/analysis-report.md
|
|
251
|
-
# ✅ CORRECT: .specweave/increments/0046/reports/analysis-report.md
|
|
252
|
-
```
|
|
253
|
-
|
|
254
|
-
**Validation**:
|
|
255
|
-
```bash
|
|
256
|
-
# Check for violations at root (should output NOTHING)
|
|
75
|
+
# Validation (should output NOTHING):
|
|
257
76
|
ls -1 .specweave/increments/ | grep -v "^[0-9]" | grep -v "^_archive" | grep -v "^README.md"
|
|
258
77
|
```
|
|
259
78
|
|
|
260
|
-
**See**: `.specweave/docs/internal/governance/increment-folder-structure.md` (complete standard)
|
|
261
|
-
|
|
262
79
|
---
|
|
263
80
|
|
|
264
|
-
|
|
81
|
+
## 3. Protected Directories
|
|
265
82
|
|
|
266
83
|
**Never delete**: `.specweave/docs/`, `.specweave/increments/`
|
|
267
|
-
|
|
268
|
-
**Pre-commit hook blocks**: Deletion of 50+ files, `rm -rf` on protected dirs
|
|
269
|
-
|
|
84
|
+
**Pre-commit hook blocks**: 50+ file deletions, `rm -rf` on protected dirs
|
|
270
85
|
**Recovery**: `git restore .specweave/`
|
|
271
86
|
|
|
272
87
|
---
|
|
273
88
|
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
**REQUIRED before `rm -rf`**:
|
|
277
|
-
1. Verify `pwd` (MUST be project root)
|
|
278
|
-
2. Dry-run with `-print` (NO deletion)
|
|
279
|
-
3. Count files to delete
|
|
280
|
-
4. Manual confirmation
|
|
281
|
-
5. Execute → Verify → Run tests
|
|
282
|
-
|
|
283
|
-
---
|
|
284
|
-
|
|
285
|
-
### 5. NEVER Use `specweave init . --force`
|
|
286
|
-
|
|
287
|
-
**Danger**: Deletes ALL increments/docs without backup
|
|
288
|
-
|
|
289
|
-
**Use**: `specweave init .` (interactive, safe)
|
|
290
|
-
|
|
291
|
-
---
|
|
292
|
-
|
|
293
|
-
### 6. Increment Completion
|
|
294
|
-
|
|
295
|
-
**Always use**: `/specweave:done 0043` (validates ACs, tasks, tests, coverage)
|
|
89
|
+
## 4-6. Safety Rules
|
|
296
90
|
|
|
297
|
-
**
|
|
91
|
+
**4. Test Cleanup**: `pwd` check → dry-run → count → confirm → execute
|
|
92
|
+
**5. NEVER**: `specweave init . --force` (deletes all without backup)
|
|
93
|
+
**6. Completion**: `/specweave:done 0043` (validates), NEVER manual `metadata.json` edit
|
|
298
94
|
|
|
299
95
|
---
|
|
300
96
|
|
|
301
|
-
|
|
97
|
+
## 7. Source of Truth: tasks.md + spec.md (CRITICAL!)
|
|
302
98
|
|
|
303
|
-
**
|
|
99
|
+
**Internal TODO is ephemeral. tasks.md + spec.md are SOURCE OF TRUTH.**
|
|
304
100
|
|
|
305
|
-
**MANDATORY workflow
|
|
101
|
+
**MANDATORY workflow**:
|
|
306
102
|
```typescript
|
|
307
|
-
// 1. Complete work
|
|
308
|
-
await
|
|
309
|
-
|
|
310
|
-
// 2. Update internal TODO
|
|
103
|
+
// 1. Complete work → 2. TodoWrite → 3. IMMEDIATELY Edit tasks.md → 4. IMMEDIATELY Edit spec.md
|
|
104
|
+
await work();
|
|
311
105
|
TodoWrite([{task: "T-013", status: "completed"}]);
|
|
312
|
-
|
|
313
|
-
// 3. IMMEDIATELY update tasks.md (NEVER skip!)
|
|
314
106
|
Edit("tasks.md", "**Status**: [ ] pending", "**Status**: [x] completed");
|
|
315
|
-
|
|
316
|
-
// 4. IMMEDIATELY update spec.md ACs
|
|
317
107
|
Edit("spec.md", "- [ ] **AC-US1-01**", "- [x] **AC-US1-01**");
|
|
318
108
|
```
|
|
319
109
|
|
|
320
|
-
**Status Line Sync
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
- Validation: `/specweave:validate-status`
|
|
324
|
-
|
|
325
|
-
**GitHub Duplicate Prevention:**
|
|
326
|
-
- **ALWAYS** use `DuplicateDetector.createWithProtection()` for GitHub issues
|
|
327
|
-
- 3-phase: Detection → Verification → Reflection (auto-close duplicates)
|
|
328
|
-
- **NEVER** use `--limit 1` in gh searches (hides duplicates, use `--limit 50`)
|
|
329
|
-
- Cleanup: `bash scripts/cleanup-duplicate-github-issues.sh --dry-run`
|
|
110
|
+
**Status Line Sync**: TodoWrite → `post-task-completion.sh` → cache updates
|
|
111
|
+
**GitHub Duplicates**: Use `DuplicateDetector.createWithProtection()`, NEVER `--limit 1` in gh searches
|
|
112
|
+
**Validation**: `/specweave:validate-status`
|
|
330
113
|
|
|
331
|
-
**Pre-closure
|
|
114
|
+
**Pre-closure check**:
|
|
332
115
|
```bash
|
|
333
|
-
grep "^\*\*Status\*\*:" tasks.md | grep -c "\[x\] completed" # Must equal
|
|
116
|
+
grep "^\*\*Status\*\*:" tasks.md | grep -c "\[x\] completed" # Must equal total
|
|
334
117
|
grep -c "^- \[x\] \*\*AC-" spec.md # Must equal total ACs
|
|
335
|
-
/specweave:done 0044
|
|
336
118
|
```
|
|
337
119
|
|
|
338
|
-
**Incidents**:
|
|
339
|
-
- 2025-11-19 (0044): Internal TODO "completed" while tasks.md showed `[ ] pending`
|
|
340
|
-
- 2025-11-20: Status line 10% desync (tasks marked without TodoWrite)
|
|
341
|
-
- 2025-11-20: 10+ duplicate GitHub issues (race conditions, --limit 1 bug)
|
|
342
|
-
|
|
343
120
|
---
|
|
344
121
|
|
|
345
|
-
### 7a. AC Presence in spec.md (MANDATORY
|
|
122
|
+
### 7a. AC Presence in spec.md (MANDATORY)
|
|
346
123
|
|
|
347
|
-
**
|
|
348
|
-
|
|
349
|
-
**Why**: The AC sync hook (`post-task-completion.sh`) requires ACs in spec.md to function. Without inline ACs, you get 0% AC completion and broken status line.
|
|
350
|
-
|
|
351
|
-
**Architecture** (ADR-0064):
|
|
352
|
-
```
|
|
353
|
-
spec.md = SOURCE OF TRUTH for ACs
|
|
354
|
-
living docs = DOCUMENTATION LAYER (optional, provides rich context)
|
|
355
|
-
```
|
|
356
|
-
|
|
357
|
-
**Validation Gates**:
|
|
358
|
-
1. `/specweave:do` (pre-start hook) - **BLOCKS** if ACs missing
|
|
359
|
-
2. `/specweave:validate` - **ERRORS** if ACs missing
|
|
360
|
-
3. `/specweave:increment` - **AUTO-EMBEDS** ACs during creation
|
|
124
|
+
**spec.md MUST contain inline ACs** even with external living docs. AC sync hook requires them.
|
|
361
125
|
|
|
362
126
|
**Required Format**:
|
|
363
127
|
```markdown
|
|
364
128
|
## Acceptance Criteria
|
|
365
|
-
|
|
366
129
|
<!-- Auto-synced from living docs -->
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
- [ ] **AC-US1-01**: Criterion description
|
|
371
|
-
- [ ] **AC-US1-02**: Criterion description
|
|
130
|
+
### US-001: Title
|
|
131
|
+
- [ ] **AC-US1-01**: Description
|
|
372
132
|
```
|
|
373
133
|
|
|
374
|
-
**If
|
|
375
|
-
|
|
376
|
-
# Manual fix: Auto-embed ACs from living docs
|
|
377
|
-
/specweave:embed-acs 0050
|
|
378
|
-
|
|
379
|
-
# Or add ACs manually to spec.md
|
|
380
|
-
Edit("spec.md", "...", "...\n\n## Acceptance Criteria\n\n...")
|
|
381
|
-
```
|
|
382
|
-
|
|
383
|
-
**Common mistake**: Generating "pointer-only" spec.md that just references living docs without embedding ACs.
|
|
384
|
-
|
|
385
|
-
**Incident** (2025-11-22, Increment 0050):
|
|
386
|
-
- spec.md had 0 inline ACs (only references to living docs)
|
|
387
|
-
- tasks.md referenced 39 ACs (AC-US1-01, AC-US4-01, etc.)
|
|
388
|
-
- AC sync hook failed: 38 warnings, 0% completion
|
|
389
|
-
- Fix: `/specweave:embed-acs 0050` → auto-embedded 39 ACs → 100% completion
|
|
390
|
-
|
|
391
|
-
**Prevention**:
|
|
392
|
-
- Pre-start hook validates AC presence before allowing work to start
|
|
393
|
-
- Spec generators auto-embed ACs when `structure: user-stories` is used
|
|
394
|
-
- Validation command checks AC count matches metadata.json
|
|
395
|
-
|
|
396
|
-
**See**: ADR-0064, `src/utils/ac-embedder.ts`, `src/core/validators/ac-presence-validator.ts`
|
|
134
|
+
**If missing**: `/specweave:embed-acs 0050` (auto-embeds from living docs)
|
|
135
|
+
**Validation**: `/specweave:do` blocks if ACs missing
|
|
397
136
|
|
|
398
137
|
---
|
|
399
138
|
|
|
400
|
-
### 7b. AC Sync Parser
|
|
401
|
-
|
|
402
|
-
**CRITICAL BUG FIXED 2025-11-24**: AC sync hook was only detecting list format checkboxes, missing field format entirely!
|
|
403
|
-
|
|
404
|
-
**The Bug**: Parser in `ac-status-manager.ts` only looked for `- [x]` list items, completely missing `**Status**: [x] completed` field format introduced in v0.23.0. This caused ALL 70 ACs in increment 0053 to show false "0% tasks complete" even though tasks.md showed 37/37 completed!
|
|
405
|
-
|
|
406
|
-
**Impact**:
|
|
407
|
-
- ❌ Data integrity violation (metadata.json polluted with false conflicts)
|
|
408
|
-
- ❌ Violated Source of Truth principle (tasks.md said "done", hook said "0%")
|
|
409
|
-
- ❌ Potential for closing increments with incomplete work (hook gave false positives)
|
|
410
|
-
|
|
411
|
-
**Root Cause** (before fix):
|
|
412
|
-
```typescript
|
|
413
|
-
// ac-status-manager.ts:137 (BROKEN - only detected list format!)
|
|
414
|
-
if (currentTaskId && line.includes('- [')) { // ❌ MISSED FIELD FORMAT!
|
|
415
|
-
if (line.includes('- [ ]')) {
|
|
416
|
-
hasUncheckedBoxes = true;
|
|
417
|
-
} else if (line.includes('- [x]')) {
|
|
418
|
-
hasCheckedBoxes = true;
|
|
419
|
-
}
|
|
420
|
-
}
|
|
421
|
-
```
|
|
139
|
+
### 7b. AC Sync Parser (v0.25.2)
|
|
422
140
|
|
|
423
|
-
**
|
|
424
|
-
```typescript
|
|
425
|
-
// Now supports BOTH formats!
|
|
426
|
-
if (currentTaskId) {
|
|
427
|
-
// 1. List format: - [x] or - [ ]
|
|
428
|
-
if (line.includes('- [')) {
|
|
429
|
-
if (line.includes('- [ ]')) {
|
|
430
|
-
hasUncheckedBoxes = true;
|
|
431
|
-
} else if (line.includes('- [x]')) {
|
|
432
|
-
hasCheckedBoxes = true;
|
|
433
|
-
}
|
|
434
|
-
}
|
|
435
|
-
// 2. Field format: **Status**: [x] completed (NEW!)
|
|
436
|
-
else if (line.match(/\*\*Status\*\*:\s*\[x\]/i)) {
|
|
437
|
-
hasCheckedBoxes = true;
|
|
438
|
-
}
|
|
439
|
-
// 3. Field format: **Status**: [ ] pending (NEW!)
|
|
440
|
-
else if (line.match(/\*\*Status\*\*:\s*\[\s\]/i)) {
|
|
441
|
-
hasUncheckedBoxes = true;
|
|
442
|
-
}
|
|
443
|
-
}
|
|
444
|
-
```
|
|
445
|
-
|
|
446
|
-
**Supported Task Formats** (both work now):
|
|
447
|
-
|
|
448
|
-
**Format 1: List items** (legacy, still supported):
|
|
449
|
-
```markdown
|
|
450
|
-
### T-001: Task Title
|
|
451
|
-
**Satisfies ACs**: AC-US1-01
|
|
452
|
-
- [x] Completed
|
|
453
|
-
- [x] Done
|
|
454
|
-
```
|
|
455
|
-
|
|
456
|
-
**Format 2: Field format** (v0.23.0+, NOW WORKS!):
|
|
457
|
-
```markdown
|
|
458
|
-
### T-001: Task Title
|
|
459
|
-
**User Story**: US-001
|
|
460
|
-
**Satisfies ACs**: AC-US1-01
|
|
461
|
-
**Priority**: P1
|
|
462
|
-
**Status**: [x] completed ← THIS NOW WORKS!
|
|
463
|
-
```
|
|
464
|
-
|
|
465
|
-
**Validation** (ensure fix is present):
|
|
466
|
-
```bash
|
|
467
|
-
# Check parser supports field format
|
|
468
|
-
grep -A 5 "Check for field format" src/core/increment/ac-status-manager.ts
|
|
469
|
-
|
|
470
|
-
# Should see: line.match(/\*\*Status\*\*:\s*\[x\]/i)
|
|
471
|
-
```
|
|
472
|
-
|
|
473
|
-
**Regression Tests** (5 new tests added):
|
|
474
|
-
```bash
|
|
475
|
-
npm test -- ac-status-manager.test.ts -t "Task status field format"
|
|
476
|
-
|
|
477
|
-
# Tests:
|
|
478
|
-
# 1. Field format detection (completed)
|
|
479
|
-
# 2. Field format detection (incomplete)
|
|
480
|
-
# 3. Mixed format support (field + list)
|
|
481
|
-
# 4. Case-insensitive matching
|
|
482
|
-
# 5. Real-world increment 0053 format
|
|
483
|
-
```
|
|
484
|
-
|
|
485
|
-
**Incident** (2025-11-24, Increment 0053):
|
|
486
|
-
- All 70 ACs showed "AC-USXX-YY: [x] but only 0/1 tasks complete (0%)"
|
|
487
|
-
- tasks.md clearly showed 37/37 tasks with `**Status**: [x] completed`
|
|
488
|
-
- Hook logged 280 conflict messages (4 acSyncEvents × 70 conflicts each)
|
|
489
|
-
- Fix: Updated parser → rebuilt → verified 0 conflicts
|
|
490
|
-
|
|
491
|
-
**Prevention**:
|
|
492
|
-
- ✅ 5 comprehensive regression tests (tests/unit/ac-status-manager.test.ts:855-1051)
|
|
493
|
-
- ✅ Tests include real-world increment 0053 format
|
|
494
|
-
- ✅ CI/CD runs all 43 AC status manager tests on every commit
|
|
495
|
-
- ✅ Emergency recovery guide: `.specweave/docs/internal/emergency-procedures/AC-SYNC-CONFLICT-FIX-2025-11-24.md`
|
|
496
|
-
|
|
497
|
-
**CRITICAL**: When introducing new task formats, ALWAYS update ALL parsers and add regression tests!
|
|
498
|
-
|
|
499
|
-
**See**: Emergency fix report (AC-SYNC-CONFLICT-FIX-2025-11-24.md), increment 0053 metadata.json (acSyncEvents)
|
|
141
|
+
**Both formats supported**: `- [x] Done` (legacy list) OR `**Status**: [x] completed` (field format)
|
|
500
142
|
|
|
501
143
|
---
|
|
502
144
|
|
|
503
|
-
|
|
145
|
+
## 8. Logger Abstraction
|
|
504
146
|
|
|
505
|
-
**Rule**: ALL `src/` code uses logger injection, NEVER `console
|
|
147
|
+
**Rule**: ALL `src/` code uses logger injection, NEVER `console.*`
|
|
506
148
|
|
|
507
149
|
```typescript
|
|
508
150
|
import { Logger, consoleLogger } from '../../utils/logger.js';
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
constructor(options: { logger?: Logger } = {}) {
|
|
512
|
-
this.logger = options.logger ?? consoleLogger;
|
|
513
|
-
}
|
|
151
|
+
constructor(options: { logger?: Logger } = {}) {
|
|
152
|
+
this.logger = options.logger ?? consoleLogger;
|
|
514
153
|
}
|
|
515
|
-
// In tests: new MyClass({ logger: silentLogger });
|
|
516
154
|
```
|
|
517
155
|
|
|
518
|
-
**Exception
|
|
519
|
-
```typescript
|
|
520
|
-
// NOTE: This CLI command is primarily user-facing output (console.log/console.error).
|
|
521
|
-
// All console.* calls are legitimate user-facing exceptions as defined in CONTRIBUTING.md.
|
|
522
|
-
```
|
|
156
|
+
**Exception**: `src/cli/commands/*.ts` may use `console.*` with comment explaining it's user-facing output
|
|
523
157
|
|
|
524
158
|
---
|
|
525
159
|
|
|
526
|
-
### 8a. Native fs
|
|
160
|
+
### 8a. Native fs
|
|
527
161
|
|
|
528
|
-
**
|
|
162
|
+
**Use native Node.js `fs`, NEVER `fs-extra`**
|
|
529
163
|
|
|
530
164
|
```typescript
|
|
531
|
-
// ✅ CORRECT
|
|
165
|
+
// ✅ CORRECT
|
|
532
166
|
import { existsSync, readFileSync } from 'fs';
|
|
533
167
|
import { promises as fs } from 'fs';
|
|
534
168
|
import { mkdirpSync, writeJsonSync } from '../utils/fs-native.js';
|
|
535
|
-
|
|
536
|
-
// ❌ WRONG: import fs from 'fs-extra';
|
|
537
169
|
```
|
|
538
170
|
|
|
539
|
-
**Migration**: `fs.existsSync → existsSync`, `fs.ensureDir → fs.mkdir(dir, {recursive: true})`, `fs.removeSync → removeSync`
|
|
540
|
-
|
|
541
|
-
**Prevention**: Pre-commit hook blocks fs-extra imports (bypass: `// legacy fs-extra`)
|
|
542
|
-
|
|
543
171
|
---
|
|
544
172
|
|
|
545
|
-
|
|
173
|
+
## 9. Coding Standards
|
|
546
174
|
|
|
547
175
|
**Critical rules (enforced)**:
|
|
548
|
-
1.
|
|
549
|
-
2.
|
|
550
|
-
3.
|
|
176
|
+
1. NEVER `console.*` (use logger)
|
|
177
|
+
2. ALWAYS `.js` extensions in imports
|
|
178
|
+
3. Test files: `.test.ts` (NEVER `.spec.ts`)
|
|
551
179
|
4. Avoid `any` type
|
|
552
180
|
5. Functions < 100 lines
|
|
553
181
|
6. Custom error types
|
|
@@ -560,149 +188,44 @@ import { mkdirpSync, writeJsonSync } from '../utils/fs-native.js';
|
|
|
560
188
|
|
|
561
189
|
---
|
|
562
190
|
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
**CRITICAL**: GitHub issues are ONLY created for User Stories, NEVER for Features!
|
|
191
|
+
## 10. GitHub Issue Format
|
|
566
192
|
|
|
567
193
|
**ONLY Correct Format**: `[FS-XXX][US-YYY] User Story Title`
|
|
568
194
|
|
|
569
|
-
**PROHIBITED
|
|
570
|
-
```
|
|
571
|
-
❌ [SP-US-XXX] ... (Deprecated SP- prefix, removed v0.24.0)
|
|
572
|
-
❌ [SP-FS-XXX] ... (Deprecated SP- prefix, removed v0.24.0)
|
|
573
|
-
❌ [SP-FS-XXX-specweave] ... (SP prefix + project suffix, DEPRECATED!)
|
|
574
|
-
❌ [FS-048] ... (Feature-only - USE MILESTONE, NOT ISSUE!)
|
|
575
|
-
❌ [FS-048-specweave] ... (Project suffix - README.md ONLY, NOT GitHub!)
|
|
576
|
-
❌ [undefined][US-XXX] ... (Missing Feature ID - validation error!)
|
|
577
|
-
```
|
|
578
|
-
|
|
579
|
-
**ONLY CORRECT Examples**:
|
|
580
|
-
```
|
|
581
|
-
✅ [FS-048][US-001] Smart Pagination During Init
|
|
582
|
-
✅ [FS-048][US-002] CLI-First Defaults
|
|
583
|
-
✅ [FS-033][US-015] Task Completion Tracking
|
|
584
|
-
```
|
|
585
|
-
|
|
586
|
-
**Architecture** (ADR-0032 Universal Hierarchy Mapping):
|
|
587
|
-
```
|
|
588
|
-
Feature FS-048 → GitHub Milestone "FS-048: Feature Title"
|
|
589
|
-
├─ User Story US-001 → Issue #XXX: [FS-048][US-001] US Title
|
|
590
|
-
├─ User Story US-002 → Issue #YYY: [FS-048][US-002] US Title
|
|
591
|
-
└─ User Story US-003 → Issue #ZZZ: [FS-048][US-003] US Title
|
|
592
|
-
```
|
|
593
|
-
|
|
594
|
-
**Create issues**:
|
|
595
|
-
```bash
|
|
596
|
-
# ✅ CORRECT: Creates User Story issues
|
|
597
|
-
/specweave-github:sync FS-048
|
|
598
|
-
|
|
599
|
-
# ❌ WRONG: /specweave:increment does NOT create GitHub issues
|
|
600
|
-
```
|
|
601
|
-
|
|
602
|
-
**Enforcement**:
|
|
603
|
-
- **Pre-commit hook**: Blocks code commits with prohibited formats
|
|
604
|
-
- **UserStoryIssueBuilder**: Runtime validation throws error if featureId invalid
|
|
605
|
-
- **Pattern matching**: Final safety check before issue creation
|
|
606
|
-
- **Manual review**: Close any wrong-format issues immediately
|
|
607
|
-
|
|
608
|
-
**If you see wrong-format issues** (e.g., `[SP-US-XXX]`, `[SP-FS-XXX]`, or `[FS-XXX]` alone):
|
|
609
|
-
1. **Close immediately** with comment: "WRONG FORMAT: Violates ADR-0032. Use [FS-XXX][US-YYY] format."
|
|
610
|
-
2. Delete any duplicate Feature folders (e.g., FS-050 when FS-048 exists)
|
|
611
|
-
3. Use `/specweave-github:sync FS-XXX` to create correct User Story issues
|
|
612
|
-
4. **REPORT THE BUG** - this should never happen with validation!
|
|
613
|
-
|
|
614
|
-
**See**:
|
|
615
|
-
- `.specweave/increments/0047-us-task-linkage/reports/FEATURE-LEVEL-GITHUB-SYNC-REMOVAL-PLAN.md`
|
|
616
|
-
- `.specweave/increments/0050-*/reports/GITHUB-ISSUE-BUG-ANALYSIS-2025-11-22.md`
|
|
617
|
-
- `.specweave/increments/0050-*/reports/SP-PREFIX-BUG-ROOT-CAUSE-2025-11-22.md`
|
|
618
|
-
|
|
619
|
-
---
|
|
620
|
-
|
|
621
|
-
### 10a. NO Increment-to-Increment References (ADR-0061) ⛔
|
|
622
|
-
|
|
623
|
-
**CRITICAL ARCHITECTURAL RULE**: Increments NEVER reference other increments!
|
|
624
|
-
|
|
625
|
-
**The Only Allowed Flow**:
|
|
626
|
-
```
|
|
627
|
-
INCREMENT (metadata.json: feature_id) → FEATURE → USER STORIES
|
|
628
|
-
```
|
|
629
|
-
|
|
630
|
-
**❌ FORBIDDEN**:
|
|
631
|
-
```yaml
|
|
632
|
-
# In user story frontmatter
|
|
633
|
-
---
|
|
634
|
-
id: US-001
|
|
635
|
-
feature: FS-048
|
|
636
|
-
increments: [0050-external-tool-import] # ❌ NEVER DO THIS!
|
|
637
|
-
---
|
|
638
|
-
```
|
|
195
|
+
**PROHIBITED**: `[SP-*]`, `[FS-XXX]` alone, `[undefined][US-XXX]`, project suffixes
|
|
639
196
|
|
|
640
|
-
|
|
641
|
-
# In user story content
|
|
642
|
-
Implemented in increment 0050-external-tool-import ❌ NEVER DO THIS!
|
|
643
|
-
```
|
|
197
|
+
**Architecture**: Feature → Milestone, User Stories → Issues
|
|
644
198
|
|
|
645
|
-
|
|
646
|
-
```yaml
|
|
647
|
-
# Increment metadata.json
|
|
648
|
-
{
|
|
649
|
-
"feature_id": "FS-048" ✅ Forward reference only
|
|
650
|
-
}
|
|
199
|
+
**Create**: `/specweave-github:sync FS-048`
|
|
651
200
|
|
|
652
|
-
# User story frontmatter
|
|
653
|
-
---
|
|
654
|
-
id: US-001
|
|
655
|
-
feature: FS-048 ✅ No increment reference needed!
|
|
656
201
|
---
|
|
657
|
-
```
|
|
658
|
-
|
|
659
|
-
**Why This Matters**:
|
|
660
|
-
|
|
661
|
-
1. **Hooks Break Without This**: The GitHub sync hook reads increment metadata → finds feature_id → finds all user stories for that feature → creates GitHub issues. If user stories required increment references, this creates circular dependencies and hooks detect 0 specs.
|
|
662
|
-
|
|
663
|
-
2. **Clean Separation**: Living docs (user stories) are permanent. Increments are temporary implementations. User stories should never know about increments.
|
|
664
202
|
|
|
665
|
-
|
|
203
|
+
### 10a. NO Increment-to-Increment References (ADR-0061)
|
|
666
204
|
|
|
667
|
-
**
|
|
668
|
-
|
|
669
|
-
- Spec-detector ignores reverse references (defensive)
|
|
670
|
-
- **See**: ADR-0061 for complete architectural rationale
|
|
205
|
+
**FORBIDDEN**: User stories referencing increments (`increments: [0050-...]`)
|
|
206
|
+
**ONLY ALLOWED**: `INCREMENT → FEATURE → USER STORIES` (forward reference only)
|
|
671
207
|
|
|
672
|
-
**
|
|
208
|
+
**Why**: Hooks break, circular dependencies, multi-increment support broken
|
|
673
209
|
|
|
674
210
|
---
|
|
675
211
|
|
|
676
|
-
|
|
212
|
+
## 11. Task Format with US Linkage
|
|
677
213
|
|
|
678
|
-
**Required fields**:
|
|
679
214
|
```markdown
|
|
680
215
|
### T-001: Task Title
|
|
681
|
-
**User Story**: US-001
|
|
682
|
-
**Satisfies ACs**: AC-US1-01
|
|
216
|
+
**User Story**: US-001 ← MANDATORY
|
|
217
|
+
**Satisfies ACs**: AC-US1-01 ← MANDATORY
|
|
683
218
|
**Status**: [x] completed
|
|
684
219
|
```
|
|
685
220
|
|
|
686
|
-
**Why**: Traceability (Task ↔ User Story ↔ AC ↔ Feature), Living docs auto-sync, AC coverage validation
|
|
687
|
-
|
|
688
|
-
**Validation**: Tasks without linkage → warnings, orphan tasks → `/specweave:done` blocks closure
|
|
689
|
-
|
|
690
221
|
---
|
|
691
222
|
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
**Correct format**: `XXXX-decision-title.md` (4-digit, kebab-case, NO `adr-` prefix)
|
|
223
|
+
## 12. ADR Naming
|
|
695
224
|
|
|
225
|
+
**Format**: `XXXX-decision-title.md` (4-digit, kebab-case, NO `adr-` prefix)
|
|
696
226
|
**Header**: `# ADR-XXXX: Decision Title`
|
|
697
|
-
|
|
698
227
|
**Location**: `.specweave/docs/internal/architecture/adr/`
|
|
699
228
|
|
|
700
|
-
```
|
|
701
|
-
✅ Filename: 0007-github-first-task-sync.md, Header: # ADR-0007: ...
|
|
702
|
-
❌ adr-0007-github-first-task-sync.md (redundant adr- prefix)
|
|
703
|
-
❌ 007-github-first-task-sync.md (3-digit)
|
|
704
|
-
```
|
|
705
|
-
|
|
706
229
|
**Auto-numbering**:
|
|
707
230
|
```bash
|
|
708
231
|
ls .specweave/docs/internal/architecture/adr/*.md | grep -E '/[0-9]{4}-' | \
|
|
@@ -712,513 +235,213 @@ ls .specweave/docs/internal/architecture/adr/*.md | grep -E '/[0-9]{4}-' | \
|
|
|
712
235
|
|
|
713
236
|
---
|
|
714
237
|
|
|
715
|
-
|
|
238
|
+
## 13. Structured Data Matching
|
|
716
239
|
|
|
717
240
|
**NEVER use string search for frontmatter/IDs**:
|
|
718
241
|
|
|
719
242
|
```typescript
|
|
720
|
-
// ❌ WRONG: Matches
|
|
721
|
-
content.
|
|
722
|
-
|
|
723
|
-
// ✅ CORRECT: Parse frontmatter explicitly
|
|
724
|
-
const match = content.match(/^feature_id:\s*["']?([^"'\n]+)["']?$/m);
|
|
725
|
-
if (match && match[1].trim() === 'FS-039') { /* ... */ }
|
|
726
|
-
|
|
727
|
-
// ❌ WRONG: Substring matching
|
|
728
|
-
archivedList.some(item => item.includes(searchId))
|
|
729
|
-
|
|
730
|
-
// ✅ CORRECT: Exact equality
|
|
731
|
-
archivedList.some(item => item === searchId)
|
|
243
|
+
// ❌ WRONG: content.includes('FS-039') // Matches "See FS-039"!
|
|
244
|
+
// ✅ CORRECT: const match = content.match(/^feature_id:\s*["']?([^"'\n]+)["']?$/m);
|
|
732
245
|
```
|
|
733
246
|
|
|
734
|
-
**Incident**: 2025-11-20 - 11 features incorrectly archived (string search false positives)
|
|
735
|
-
|
|
736
247
|
---
|
|
737
248
|
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
**NEVER add incomplete plugins to marketplace.json**
|
|
249
|
+
## 14. Marketplace Plugin Completeness
|
|
741
250
|
|
|
742
251
|
**Complete plugin requires**: `agents/`, `commands/`, OR `lib/` (not just `.claude-plugin/` + `skills/`)
|
|
743
252
|
|
|
744
|
-
**MANDATORY
|
|
745
|
-
```bash
|
|
746
|
-
bash scripts/validate-marketplace-plugins.sh # Must see "✅ VALIDATION PASSED!"
|
|
747
|
-
```
|
|
748
|
-
|
|
749
|
-
**Adding new plugin**:
|
|
750
|
-
1. Create with agents/commands/lib (NOT empty dirs!)
|
|
751
|
-
2. Add to marketplace.json
|
|
752
|
-
3. **VALIDATE** (critical!)
|
|
753
|
-
4. Update `bin/fix-marketplace-errors.sh`
|
|
754
|
-
5. Test: `npm pack && npm i -g ./specweave-*.tgz`
|
|
755
|
-
|
|
756
|
-
**Incident**: 2025-11-20 - 8 incomplete plugins failed loading on global install
|
|
253
|
+
**MANDATORY**: `bash scripts/validate-marketplace-plugins.sh`
|
|
757
254
|
|
|
758
255
|
---
|
|
759
256
|
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
**Key Differences**:
|
|
257
|
+
## 15. Skills vs Agents
|
|
763
258
|
|
|
764
259
|
| Aspect | Skills | Agents |
|
|
765
260
|
|--------|--------|--------|
|
|
766
261
|
| **Location** | `plugins/*/skills/name/SKILL.md` | `plugins/*/agents/name/AGENT.md` |
|
|
767
262
|
| **Invocation** | `Skill()` or `/command` | `Task()` with `subagent_type` |
|
|
768
|
-
| **Activation** | Automatic (keywords) | Explicit
|
|
769
|
-
| **File** | `SKILL.md` (YAML frontmatter) | `AGENT.md` |
|
|
263
|
+
| **Activation** | Automatic (keywords) | Explicit |
|
|
770
264
|
|
|
771
265
|
**Agent naming**: `{plugin}:{directory}:{yaml-name}`
|
|
772
266
|
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
267
|
+
### Skills Must NOT Spawn Large Content-Generating Agents (ADR-0133)
|
|
268
|
+
|
|
269
|
+
**CRITICAL**: Skills spawning agents via `Task()` causes Claude Code crashes due to context explosion.
|
|
776
270
|
|
|
777
|
-
|
|
778
|
-
Task({ subagent_type: "specweave:qa-lead:qa-lead", prompt: "..." });
|
|
271
|
+
**Problem**: Skill (1500 lines) + Agent (600 lines) + Agent output (2000+ lines) = 4000+ lines in memory = CRASH 💥
|
|
779
272
|
|
|
780
|
-
|
|
781
|
-
|
|
273
|
+
**❌ FORBIDDEN**:
|
|
274
|
+
```typescript
|
|
275
|
+
// In a skill SKILL.md:
|
|
276
|
+
Task({
|
|
277
|
+
subagent_type: "specweave:architect:architect", // ❌ Generates 1000-3000 lines
|
|
278
|
+
subagent_type: "specweave:pm:pm", // ❌ Generates 500-2000 lines
|
|
279
|
+
subagent_type: "specweave:test-aware-planner", // ❌ Generates 500-1500 lines
|
|
280
|
+
});
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
**✅ CORRECT**:
|
|
284
|
+
```typescript
|
|
285
|
+
// Skills create templates and guide users:
|
|
286
|
+
1. Create basic templates (< 50 lines each)
|
|
287
|
+
2. Output: "Tell Claude: 'Complete the spec for increment 0005-feature'"
|
|
288
|
+
3. Agents activate in MAIN context (not nested) = SAFE
|
|
782
289
|
```
|
|
783
290
|
|
|
784
|
-
**
|
|
291
|
+
**When to use Task() from skills**:
|
|
292
|
+
- ✅ Small utility agents (output < 200 lines)
|
|
293
|
+
- ✅ Data processing agents (no large generation)
|
|
294
|
+
- ❌ Content generators (specs, ADRs, plans, tasks)
|
|
785
295
|
|
|
786
|
-
**
|
|
296
|
+
**Reference**: ADR-0133, Architect crash incident (2025-11-24, Increment 0052)
|
|
787
297
|
|
|
788
298
|
---
|
|
789
299
|
|
|
790
|
-
|
|
300
|
+
## 16. YAML Frontmatter
|
|
791
301
|
|
|
792
|
-
**Required
|
|
302
|
+
**Required**:
|
|
793
303
|
```yaml
|
|
794
304
|
---
|
|
795
305
|
increment: 0001-feature-name # REQUIRED: 4-digit + kebab-case
|
|
796
|
-
title: Feature Title # OPTIONAL
|
|
797
306
|
feature_id: FS-001 # OPTIONAL
|
|
798
307
|
---
|
|
799
308
|
```
|
|
800
309
|
|
|
801
|
-
**
|
|
802
|
-
|
|
803
|
-
**Validation layers**:
|
|
804
|
-
1. Pre-commit hook: `scripts/pre-commit-yaml-validation.sh`
|
|
805
|
-
2. Spec parser (uses `js-yaml`, provides line numbers)
|
|
806
|
-
3. `/specweave:validate 0001`
|
|
807
|
-
|
|
808
|
-
**Manual test**:
|
|
809
|
-
```bash
|
|
810
|
-
node -e "const yaml = require('js-yaml'); const fs = require('fs'); \
|
|
811
|
-
const content = fs.readFileSync('.specweave/increments/0001-test/spec.md', 'utf-8'); \
|
|
812
|
-
const fm = content.match(/^---\n([\s\S]*?)\n---/); \
|
|
813
|
-
console.log('✅ Valid:', JSON.stringify(yaml.load(fm[1]), null, 2));"
|
|
814
|
-
```
|
|
310
|
+
**Validation**: Pre-commit hook, spec parser, `/specweave:validate 0001`
|
|
815
311
|
|
|
816
312
|
---
|
|
817
313
|
|
|
818
|
-
## 17. Git Provider Abstraction
|
|
819
|
-
|
|
820
|
-
**Architecture**: Interface-driven multi-platform support with registry pattern
|
|
314
|
+
## 17. Git Provider Abstraction
|
|
821
315
|
|
|
822
|
-
**
|
|
823
|
-
-
|
|
824
|
-
- `src/core/repo-structure/platform-registry.ts` - Singleton registry
|
|
825
|
-
- `src/core/repo-structure/providers/` - Platform implementations
|
|
316
|
+
**Interface-driven multi-platform support**:
|
|
317
|
+
- GitHub, GitLab, Bitbucket, Azure DevOps, Local Git
|
|
826
318
|
|
|
827
|
-
**
|
|
319
|
+
**Usage**:
|
|
828
320
|
```typescript
|
|
829
|
-
export interface GitProvider {
|
|
830
|
-
readonly config: GitProviderConfig;
|
|
831
|
-
|
|
832
|
-
validateRepository(owner: string, repo: string, token?: string): Promise<ValidationResult>;
|
|
833
|
-
validateOwner(owner: string, token?: string): Promise<OwnerValidationResult>;
|
|
834
|
-
createRepository(params: CreateRepoParams, token: string): Promise<string>;
|
|
835
|
-
isOrganization(owner: string, token?: string): Promise<boolean>;
|
|
836
|
-
|
|
837
|
-
getRemoteUrl(owner: string, repo: string, urlType: 'ssh' | 'https'): string;
|
|
838
|
-
getTokenUrl(): string;
|
|
839
|
-
getRequiredScopes(isOrg: boolean): string[];
|
|
840
|
-
}
|
|
841
|
-
```
|
|
842
|
-
|
|
843
|
-
**Usage pattern**:
|
|
844
|
-
```typescript
|
|
845
|
-
import { initializeProviders } from './providers/index.js';
|
|
846
321
|
import { getPlatformRegistry } from './platform-registry.js';
|
|
847
|
-
|
|
848
|
-
// Initialize providers (call once during startup)
|
|
849
|
-
initializeProviders();
|
|
850
|
-
|
|
851
|
-
// Get provider for user-selected platform
|
|
852
|
-
const registry = getPlatformRegistry();
|
|
853
|
-
const provider = registry.getProvider('github'); // or 'gitlab', 'bitbucket'
|
|
854
|
-
|
|
855
|
-
// Use provider methods (platform-agnostic code)
|
|
322
|
+
const provider = registry.getProvider('github');
|
|
856
323
|
const result = await provider.validateRepository('owner', 'repo', token);
|
|
857
|
-
const url = provider.getRemoteUrl('owner', 'repo', 'ssh');
|
|
858
|
-
await provider.createRepository({ owner, name, description, visibility }, token);
|
|
859
324
|
```
|
|
860
325
|
|
|
861
|
-
**
|
|
862
|
-
- ✅ GitHub (fully supported): `github-provider.ts`
|
|
863
|
-
- ✅ GitLab (fully supported): `gitlab-provider.ts`
|
|
864
|
-
- ✅ Bitbucket (fully supported): `bitbucket-provider.ts`
|
|
865
|
-
- ✅ Azure DevOps (fully supported): `azure-devops-provider.ts`
|
|
866
|
-
- ✅ Local Git (fully supported): `local-provider.ts`
|
|
326
|
+
**NEVER**: Hardcode platform names, API endpoints, Git hosts
|
|
867
327
|
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
3. Register in `providers/index.ts`: `registry.registerProvider('platform', provider)`
|
|
872
|
-
4. Update platform registry metadata: `registry.registerPlatform({ type, name, description, supported })`
|
|
328
|
+
---
|
|
329
|
+
|
|
330
|
+
### 17a. GitHub Multi-Repo Init Flow (v0.26.3 - ADR-0132)
|
|
873
331
|
|
|
874
|
-
**NEVER
|
|
875
|
-
- ❌ Hardcode platform names (use `provider.config.name`)
|
|
876
|
-
- ❌ Hardcode API endpoints (use `provider.config.apiBaseUrl`)
|
|
877
|
-
- ❌ Hardcode Git hosts (use `provider.config.host`)
|
|
878
|
-
- ❌ Use GitHub-specific methods (use provider interface)
|
|
332
|
+
**Rule**: NEVER early returns in routing code. Use mapping.
|
|
879
333
|
|
|
880
|
-
|
|
334
|
+
```typescript
|
|
335
|
+
// ❌ if (option === 'advanced') return { type: 'basic' };
|
|
336
|
+
// ✅ let mapped = undefined; if (option === 'advanced') mapped = 'enhanced';
|
|
337
|
+
```
|
|
881
338
|
|
|
882
339
|
---
|
|
883
340
|
|
|
884
|
-
##
|
|
341
|
+
## Sync Orchestration Architecture (v0.26.3+)
|
|
342
|
+
|
|
343
|
+
### **How GitHub Issue Sync Works**
|
|
885
344
|
|
|
345
|
+
**3-Phase Sync Flow**:
|
|
886
346
|
```
|
|
887
|
-
|
|
888
|
-
plugins/ # Skills, agents, commands, hooks
|
|
889
|
-
├── specweave/ # Core plugin
|
|
890
|
-
└── specweave-*/ # Optional plugins
|
|
891
|
-
.specweave/ # Increments, docs, logs
|
|
347
|
+
TodoWrite → Hook → US Completion Orchestrator → Living Docs Sync → External Tool Sync → GitHub Issues Updated
|
|
892
348
|
```
|
|
893
349
|
|
|
894
|
-
**
|
|
350
|
+
**Phase 1: Task Completion Detection**
|
|
351
|
+
- User marks task complete via `TodoWrite`
|
|
352
|
+
- `post-task-completion.sh` fires (sets `SKIP_GITHUB_SYNC=true` to prevent duplicate syncs)
|
|
353
|
+
- `consolidated-sync.js` runs 6 operations sequentially
|
|
895
354
|
|
|
896
|
-
|
|
355
|
+
**Phase 2: US Completion Orchestration**
|
|
356
|
+
- `syncCompletedUserStories()` (operation 5 of 6) detects newly completed user stories
|
|
357
|
+
- Checks if all ACs for a US are complete (100% → status: "completed")
|
|
358
|
+
- **Throttle**: 60s window prevents spam (manual override: `/specweave:sync-progress`)
|
|
359
|
+
- If newly completed USs found → triggers Phase 3
|
|
897
360
|
|
|
898
|
-
|
|
361
|
+
**Phase 3: External Tool Sync**
|
|
362
|
+
- `LivingDocsSync.syncIncrement()` called
|
|
363
|
+
- `detectExternalTools()` checks **3 levels** for GitHub config:
|
|
364
|
+
- **Level 1**: `metadata.json` (increment-cached links)
|
|
365
|
+
- **Level 2**: `config.json` - **4 detection methods** (ADR-0137):
|
|
366
|
+
- Method 1: `config.sync.github.enabled` ← **Most common (60% of users)**
|
|
367
|
+
- Method 2: `config.sync.profiles[activeProfile]` ← Multi-profile setups
|
|
368
|
+
- Method 3: `config.multiProject.projects[project].externalTools.github` ← Multi-project
|
|
369
|
+
- Method 4: `config.plugins.settings['specweave-github']` ← Legacy
|
|
370
|
+
- **Level 3**: Environment variables (`GITHUB_TOKEN` + `GITHUB_OWNER`/`GITHUB_REPOSITORY`)
|
|
371
|
+
- If GitHub detected → `syncToGitHub()` → `GitHubFeatureSync.syncFeatureToGitHub()`
|
|
372
|
+
- Updates GitHub issues with completed AC checkboxes
|
|
899
373
|
|
|
900
|
-
**
|
|
374
|
+
### **GitHub Configuration (Required)**
|
|
901
375
|
|
|
902
|
-
**
|
|
376
|
+
**Recommended Setup (Pattern 1 - Simplest)**:
|
|
903
377
|
```json
|
|
378
|
+
// .specweave/config.json
|
|
904
379
|
{
|
|
905
|
-
"
|
|
906
|
-
"
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
"command": "${CLAUDE_PLUGIN_ROOT}/hooks/post-task-completion.sh",
|
|
912
|
-
"timeout": 10
|
|
913
|
-
}]
|
|
914
|
-
}
|
|
915
|
-
]
|
|
380
|
+
"sync": {
|
|
381
|
+
"github": {
|
|
382
|
+
"enabled": true,
|
|
383
|
+
"owner": "your-org",
|
|
384
|
+
"repo": "your-repo"
|
|
385
|
+
}
|
|
916
386
|
}
|
|
917
387
|
}
|
|
918
388
|
```
|
|
919
389
|
|
|
920
|
-
|
|
921
|
-
**✅ CORRECT**: `"PostToolUse"` with `"matcher": "TodoWrite"`
|
|
922
|
-
|
|
923
|
-
---
|
|
924
|
-
|
|
925
|
-
## 9a. Hook Performance & Safety (CRITICAL - v0.25.0)
|
|
926
|
-
|
|
927
|
-
**Critical incidents**:
|
|
928
|
-
- 2025-11-22 - Multiple Claude Code crashes due to hook overhead
|
|
929
|
-
- 2025-11-23 - Hook process storm (6 hooks per Edit/Write → 300 processes/min)
|
|
930
|
-
- 2025-11-24 (AM) - PROJECT_ROOT order bug (recursion guard at wrong path → crashes)
|
|
931
|
-
- **2025-11-24 (PM) - TodoWrite crash: US sync triggers unguarded external tool cascade → infinite recursion** ⚠️
|
|
932
|
-
|
|
933
|
-
**Root cause**:
|
|
934
|
-
- **Original**: Process exhaustion from spawning 6 bash processes per Edit/Write operation
|
|
935
|
-
- **NEW (v0.25.1)**: US completion orchestrator triggers `livingDocsSync.syncIncrement()` which calls `syncToExternalTools()` without checking `SKIP_GITHUB_SYNC` → Edit/Write operations → new hook chains → infinite recursion → crash
|
|
936
|
-
|
|
937
|
-
**LONG-TERM FIX (v0.25.0)**: Hook Consolidation
|
|
938
|
-
- **Reduced from 6 → 4 hooks per Edit/Write** (33% reduction)
|
|
939
|
-
- **Consolidated hooks**:
|
|
940
|
-
- `pre-edit-write-consolidated.sh` (replaces pre-edit-spec + pre-write-spec)
|
|
941
|
-
- `post-edit-write-consolidated.sh` (replaces post-edit-spec + post-write-spec)
|
|
942
|
-
- `post-metadata-change.sh` (enhanced with ultra-fast early exit)
|
|
943
|
-
- **Performance**: 50% reduction in hook overhead
|
|
944
|
-
- **See**: ADR-0070 (Hook Consolidation)
|
|
945
|
-
|
|
946
|
-
**Emergency fixes implemented (v0.24.3)**:
|
|
947
|
-
|
|
948
|
-
### 1. Emergency Kill Switch
|
|
390
|
+
**Plus `.env`**:
|
|
949
391
|
```bash
|
|
950
|
-
|
|
951
|
-
|
|
392
|
+
GITHUB_TOKEN=ghp_your_token_here
|
|
393
|
+
GITHUB_OWNER=your-org # Optional if in config.json
|
|
394
|
+
GITHUB_REPO=your-repo # Optional if in config.json
|
|
952
395
|
```
|
|
953
396
|
|
|
954
|
-
|
|
955
|
-
- **Threshold**: 3 consecutive failures → auto-disable hooks
|
|
956
|
-
- **File**: `.specweave/state/.hook-circuit-breaker`
|
|
957
|
-
- **Recovery**: `rm .specweave/state/.hook-circuit-breaker`
|
|
958
|
-
|
|
959
|
-
### 3. File Locking (Prevents Concurrent Execution)
|
|
960
|
-
- **Max instances**: 1 per hook type
|
|
961
|
-
- **Timeout**: 5-10 seconds with stale lock cleanup
|
|
962
|
-
- **Mechanism**: Directory-based mutex
|
|
397
|
+
**Diagnostic**: Run `node dist/test-github-detection.js` to verify detection (create this file if needed)
|
|
963
398
|
|
|
964
|
-
###
|
|
965
|
-
- **Window**: 5 seconds (increased from 1s)
|
|
966
|
-
- **Effect**: Batches rapid operations
|
|
967
|
-
- **Trade-off**: 5s staleness acceptable for UX
|
|
399
|
+
### **Troubleshooting Sync Issues**
|
|
968
400
|
|
|
969
|
-
|
|
401
|
+
**Issue**: GitHub issues not updating after US completion
|
|
402
|
+
**Diagnosis**:
|
|
970
403
|
```bash
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
### 6. Consolidated Background Work
|
|
976
|
-
- **Before**: 6+ Node.js spawns per task (exhaustion!)
|
|
977
|
-
- **After**: 1 consolidated background job
|
|
978
|
-
- **Reduction**: 85% fewer processes
|
|
979
|
-
|
|
980
|
-
### Hook Safety Checklist (MANDATORY)
|
|
981
|
-
|
|
982
|
-
**✅ EVERY hook MUST have**:
|
|
983
|
-
1. `PROJECT_ROOT` defined BEFORE any path variables (CRITICAL - v0.26.1)
|
|
984
|
-
2. Kill switch check (`SPECWEAVE_DISABLE_HOOKS`)
|
|
985
|
-
3. Circuit breaker check (3 failure threshold)
|
|
986
|
-
4. File locking (prevent concurrent runs)
|
|
987
|
-
5. Debouncing (5s minimum)
|
|
988
|
-
6. Error isolation (`set +e`, `exit 0`)
|
|
989
|
-
7. Background work wrapped in subshell
|
|
990
|
-
8. Circuit breaker updates on success/failure
|
|
991
|
-
|
|
992
|
-
**❌ NEVER in hooks**:
|
|
993
|
-
- `set -e` (causes crashes)
|
|
994
|
-
- Synchronous Node.js spawns
|
|
995
|
-
- Multiple separate background jobs
|
|
996
|
-
- Error propagation to Claude Code
|
|
997
|
-
- Missing `exit 0` at end
|
|
998
|
-
|
|
999
|
-
### Performance Targets
|
|
1000
|
-
|
|
1001
|
-
| Metric | Target | Warning | Critical |
|
|
1002
|
-
|--------|--------|---------|----------|
|
|
1003
|
-
| Hook execution | <100ms | 100-500ms | >500ms |
|
|
1004
|
-
| Background processes | 0-2 | 3-5 | 6+ |
|
|
1005
|
-
| Circuit breaker count | 0 | 1-2 | 3 (open) |
|
|
1006
|
-
|
|
1007
|
-
### Emergency Recovery
|
|
1008
|
-
|
|
1009
|
-
**If Claude Code crashes**:
|
|
1010
|
-
```bash
|
|
1011
|
-
# 1. Immediate kill switch
|
|
1012
|
-
export SPECWEAVE_DISABLE_HOOKS=1
|
|
404
|
+
# 1. Check detection
|
|
405
|
+
grep "External tools detected" .specweave/logs/hooks-debug.log | tail -5
|
|
406
|
+
# Should see: "📡 External tools detected: github"
|
|
1013
407
|
|
|
1014
|
-
# 2.
|
|
1015
|
-
|
|
408
|
+
# 2. Check config
|
|
409
|
+
cat .specweave/config.json | jq '.sync.github'
|
|
410
|
+
# Should have: enabled: true, owner: "...", repo: "..."
|
|
1016
411
|
|
|
1017
|
-
# 3.
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
# 4. Rebuild
|
|
1021
|
-
npm run rebuild
|
|
412
|
+
# 3. Check throttle
|
|
413
|
+
grep "throttled" .specweave/logs/hooks-debug.log | tail -3
|
|
414
|
+
# If throttled → wait 60s OR run: /specweave:sync-progress
|
|
1022
415
|
```
|
|
1023
416
|
|
|
1024
|
-
**
|
|
1025
|
-
|
|
1026
|
-
- ADR-0060 (Three-tier optimization architecture)
|
|
1027
|
-
- `.specweave/increments/0050-*/reports/hook-crash-analysis.md` (Incident analysis)
|
|
1028
|
-
|
|
1029
|
-
### Active Increment Filtering (v0.24.4 - ARCHITECTURAL FIX)
|
|
1030
|
-
|
|
1031
|
-
**Critical architectural change**: Hooks now **ONLY** process active increments.
|
|
1032
|
-
|
|
1033
|
-
**Problem**: The old logic used `ls -td` (time-based) which:
|
|
1034
|
-
- Processed 50+ increments on every TodoWrite
|
|
1035
|
-
- Could pick completed increments if recently modified
|
|
1036
|
-
- Caused infinite loops when hitting bad AC data
|
|
1037
|
-
- Wasted 90%+ of hook overhead on completed work
|
|
1038
|
-
|
|
1039
|
-
**Solution**: State-based filtering (`.specweave/state/active-increment.json`)
|
|
1040
|
-
|
|
1041
|
-
```bash
|
|
1042
|
-
# NEW: Read active increments from state file
|
|
1043
|
-
mapfile -t ACTIVE_INCREMENTS < <(jq -r '.ids[]' "$ACTIVE_STATE_FILE")
|
|
1044
|
-
|
|
1045
|
-
# Process ONLY active increments
|
|
1046
|
-
for CURRENT_INCREMENT in "${ACTIVE_INCREMENTS[@]}"; do
|
|
1047
|
-
# Safety: Skip if completed/abandoned/archived
|
|
1048
|
-
if [[ "$STATUS" == "completed" ]] || [[ "$STATUS" == "abandoned" ]]; then
|
|
1049
|
-
continue
|
|
1050
|
-
fi
|
|
1051
|
-
|
|
1052
|
-
# Process (tasks.md, AC sync, living docs, etc.)
|
|
1053
|
-
done
|
|
1054
|
-
```
|
|
1055
|
-
|
|
1056
|
-
**Impact**:
|
|
1057
|
-
- ✅ 95% reduction in hook overhead (50+ → 1-2 increments)
|
|
1058
|
-
- ✅ Zero risk of infinite loops (completed increments never touched)
|
|
1059
|
-
- ✅ Clean architecture (source of truth: state file)
|
|
1060
|
-
- ✅ Multi-increment support (processes array)
|
|
1061
|
-
|
|
1062
|
-
**Fail-safe defaults**:
|
|
1063
|
-
- No state file → skip all work
|
|
1064
|
-
- Empty array → skip all work (normal when no active increments)
|
|
1065
|
-
- Missing directory → skip increment
|
|
1066
|
-
- Archived → skip increment
|
|
1067
|
-
- Completed/abandoned status → skip increment
|
|
1068
|
-
|
|
1069
|
-
**See**: `.specweave/increments/0050-*/reports/ARCHITECTURAL-FIX-ACTIVE-INCREMENT-FILTERING.md`
|
|
1070
|
-
|
|
1071
|
-
### Hook Variable Initialization Order (v0.26.1 - CRITICAL FIX)
|
|
1072
|
-
|
|
1073
|
-
**CRITICAL BUG PATTERN**: Variables used in path construction MUST be defined BEFORE they're used!
|
|
1074
|
-
|
|
1075
|
-
**Incident** (2025-11-24): Claude Code crashed 3x due to `PROJECT_ROOT` being used before definition in `post-task-completion.sh`.
|
|
1076
|
-
|
|
1077
|
-
**The Bug**:
|
|
1078
|
-
```bash
|
|
1079
|
-
# ❌ WRONG: Uses $PROJECT_ROOT before it's defined
|
|
1080
|
-
RECURSION_GUARD_FILE="$PROJECT_ROOT/.specweave/state/.hook-recursion-guard" # Line 71
|
|
1081
|
-
# ... 40 lines later ...
|
|
1082
|
-
PROJECT_ROOT="$(find_project_root ...)" # Line 112 - TOO LATE!
|
|
1083
|
-
|
|
1084
|
-
# Result: Guard file created at wrong path (/.specweave/state/...)
|
|
1085
|
-
```
|
|
1086
|
-
|
|
1087
|
-
**What Happened**:
|
|
1088
|
-
1. Guard file created at **invalid path** (`/.specweave/state/.hook-recursion-guard`)
|
|
1089
|
-
2. Other hooks check guard at **correct path** (`/full/project/path/.specweave/state/...`)
|
|
1090
|
-
3. Guard not found → hooks don't exit early → **INFINITE RECURSION**
|
|
1091
|
-
4. PreToolUse hook fired 3x → Claude Code crashed
|
|
1092
|
-
|
|
1093
|
-
**✅ CORRECT Pattern**:
|
|
417
|
+
**Issue**: Throttle blocking sync
|
|
418
|
+
**Solution**: Manual sync (bypasses throttle):
|
|
1094
419
|
```bash
|
|
1095
|
-
#
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
# 2. Set PROJECT_ROOT IMMEDIATELY (line 50)
|
|
1099
|
-
PROJECT_ROOT="$(find_project_root ...)"
|
|
1100
|
-
|
|
1101
|
-
# 3. NOW use PROJECT_ROOT in paths (line 60+)
|
|
1102
|
-
RECURSION_GUARD_FILE="$PROJECT_ROOT/.specweave/state/.hook-recursion-guard"
|
|
420
|
+
/specweave:sync-progress 0054 # Sync specific increment
|
|
421
|
+
/specweave-github:sync FS-054 # Sync entire feature
|
|
1103
422
|
```
|
|
1104
423
|
|
|
1105
|
-
**
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
424
|
+
**Issue**: Detection not finding GitHub config
|
|
425
|
+
**Fix**: ADR-0137 enhanced detection (v0.26.3+)
|
|
426
|
+
- Checks 4 config locations + env vars
|
|
427
|
+
- Update to latest version: `npm update specweave`
|
|
1109
428
|
|
|
1110
|
-
|
|
1111
|
-
# If fails: Script shows exactly which hooks have wrong variable order
|
|
1112
|
-
```
|
|
429
|
+
## Hook Performance & Safety
|
|
1113
430
|
|
|
1114
|
-
**
|
|
1115
|
-
- ✅ Pre-commit hook added: runs `validate-hook-variable-order.sh` on every commit
|
|
1116
|
-
- ✅ Regression tests added: `tests/unit/hooks/recursion-guard.test.ts` (29 tests)
|
|
1117
|
-
- ✅ Validates all hooks with RECURSION_GUARD_FILE have correct variable order
|
|
1118
|
-
- ✅ Blocks commits where `PROJECT_ROOT` is defined after `RECURSION_GUARD_FILE`
|
|
431
|
+
**Emergency**: `export SPECWEAVE_DISABLE_HOOKS=1` → `rm -f .specweave/state/.hook-*` → `npm run rebuild`
|
|
1119
432
|
|
|
1120
|
-
**
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
hook="plugins/specweave/hooks/post-task-completion.sh"
|
|
1124
|
-
guard_line=$(grep -n "^RECURSION_GUARD_FILE=" "$hook" | cut -d: -f1)
|
|
1125
|
-
root_line=$(grep -n "^PROJECT_ROOT=" "$hook" | cut -d: -f1)
|
|
1126
|
-
echo "PROJECT_ROOT: line $root_line"
|
|
1127
|
-
echo "RECURSION_GUARD_FILE: line $guard_line"
|
|
1128
|
-
# root_line MUST be < guard_line
|
|
1129
|
-
```
|
|
433
|
+
**Mandatory Checklist**: PROJECT_ROOT first, kill switch, circuit breaker, file lock, debounce (5s), `set +e`, `exit 0`, active-only filtering
|
|
434
|
+
**Never**: `set -e`, sync spawns, error propagation
|
|
435
|
+
**Targets**: <100ms, 0-2 processes, 0 breaker trips
|
|
1130
436
|
|
|
1131
|
-
**
|
|
1132
|
-
-
|
|
1133
|
-
-
|
|
1134
|
-
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
**CRITICAL BUG**: Marking tasks complete via TodoWrite crashes Claude Code due to unguarded external tool sync cascade.
|
|
1141
|
-
|
|
1142
|
-
**Incident** (2025-11-24 PM): User reported Claude Code crash when marking tasks complete in increment 0053-safe-feature-deletion.
|
|
1143
|
-
|
|
1144
|
-
**Root Cause**:
|
|
1145
|
-
1. US completion orchestrator (`us-completion-orchestrator.js`) detects all 6 USs as "newly complete" (perfect storm when last task marked)
|
|
1146
|
-
2. Calls `livingDocsSync.syncIncrement()` without checking `SKIP_US_SYNC` flag
|
|
1147
|
-
3. Living docs sync calls `syncToExternalTools()` without checking `SKIP_GITHUB_SYNC` flag
|
|
1148
|
-
4. External tool sync creates/updates GitHub issues (Edit/Write operations)
|
|
1149
|
-
5. Edit/Write hooks trigger NEW hook chains (recursion guard doesn't protect Edit/Write events)
|
|
1150
|
-
6. **Infinite recursion** → Process exhaustion → Claude Code crash
|
|
1151
|
-
|
|
1152
|
-
**Crash Flow**:
|
|
1153
|
-
```
|
|
1154
|
-
TodoWrite → post-task-completion.sh
|
|
1155
|
-
→ consolidated-sync.js (operation 5/6)
|
|
1156
|
-
→ us-completion-orchestrator.js
|
|
1157
|
-
→ livingDocsSync.syncIncrement()
|
|
1158
|
-
→ syncToExternalTools() ← NO GUARD!
|
|
1159
|
-
→ syncToGitHub()
|
|
1160
|
-
→ Edit/Write operations
|
|
1161
|
-
→ NEW HOOK CHAIN
|
|
1162
|
-
→ INFINITE RECURSION
|
|
1163
|
-
→ 💥 CRASH
|
|
1164
|
-
```
|
|
1165
|
-
|
|
1166
|
-
**Emergency Hotfix** (v0.25.1 - ✅ DEPLOYED):
|
|
1167
|
-
```bash
|
|
1168
|
-
# File: plugins/specweave/hooks/post-task-completion.sh (line 463)
|
|
1169
|
-
export SKIP_US_SYNC=true
|
|
1170
|
-
```
|
|
1171
|
-
|
|
1172
|
-
**Impact**:
|
|
1173
|
-
- ✅ **NO MORE CRASHES**: TodoWrite is now safe
|
|
1174
|
-
- ⚠️ **Manual sync required**: Must run `/specweave:sync-progress` after completing tasks
|
|
1175
|
-
- ✅ **Living docs still work**: AC sync, tasks.md updates, status line all function
|
|
1176
|
-
|
|
1177
|
-
**Verification**:
|
|
1178
|
-
```bash
|
|
1179
|
-
# 1. Check hotfix applied
|
|
1180
|
-
grep "SKIP_US_SYNC=true" plugins/specweave/hooks/post-task-completion.sh
|
|
1181
|
-
|
|
1182
|
-
# 2. Test task completion
|
|
1183
|
-
TodoWrite([{ content: "T-001", status: "completed" }])
|
|
1184
|
-
|
|
1185
|
-
# 3. Verify no crash
|
|
1186
|
-
tail -50 .specweave/logs/hooks-debug.log | grep "SKIP_US_SYNC"
|
|
1187
|
-
# Expected: ℹ️ User story sync skipped (SKIP_US_SYNC=true)
|
|
1188
|
-
|
|
1189
|
-
# 4. Manual sync when ready
|
|
1190
|
-
/specweave:sync-progress 0053
|
|
1191
|
-
```
|
|
1192
|
-
|
|
1193
|
-
**Long-Term Fix** (v0.26.0 - PLANNED):
|
|
1194
|
-
- **Tier 1**: Add `SKIP_EXTERNAL_SYNC` check in `LivingDocsSync.syncIncrement()`
|
|
1195
|
-
- **Tier 2**: Universal recursion guard (ALL hooks check same guard file)
|
|
1196
|
-
- **Tier 3**: Smart throttling (60-second window for US sync)
|
|
1197
|
-
- **Result**: Restore automatic US sync (now safe with guard rails!)
|
|
1198
|
-
|
|
1199
|
-
**Recovery** (If crash occurs):
|
|
1200
|
-
```bash
|
|
1201
|
-
# 1. Kill stuck processes
|
|
1202
|
-
ps aux | grep -E "consolidated-sync|us-completion" | awk '{print $2}' | xargs kill -9
|
|
1203
|
-
|
|
1204
|
-
# 2. Disable hooks
|
|
1205
|
-
export SPECWEAVE_DISABLE_HOOKS=1
|
|
1206
|
-
|
|
1207
|
-
# 3. Clean locks
|
|
1208
|
-
rm -rf .specweave/state/.hook-*.lock
|
|
1209
|
-
rm -f .specweave/state/.hook-recursion-guard
|
|
1210
|
-
|
|
1211
|
-
# 4. Apply hotfix (see above)
|
|
1212
|
-
|
|
1213
|
-
# 5. Re-enable hooks
|
|
1214
|
-
unset SPECWEAVE_DISABLE_HOOKS
|
|
1215
|
-
```
|
|
1216
|
-
|
|
1217
|
-
**See**:
|
|
1218
|
-
- `.specweave/increments/0053-safe-feature-deletion/reports/EXECUTIVE-SUMMARY-CRASH-FIX-2025-11-24.md` (Executive summary)
|
|
1219
|
-
- `.specweave/increments/0053-safe-feature-deletion/reports/ROOT-CAUSE-ANALYSIS-TODOWRITE-CRASH-2025-11-24.md` (Detailed analysis)
|
|
1220
|
-
- `.specweave/docs/internal/emergency-procedures/TODOWRITE-CRASH-RECOVERY.md` (Recovery guide)
|
|
1221
|
-
- `.specweave/docs/internal/architecture/adr/0129-us-sync-guard-rails.md` (ADR-0129)
|
|
437
|
+
**Critical Fixes**:
|
|
438
|
+
- v0.26.3: **Multi-location GitHub config detection!** (ADR-0137) → Checks 4 config patterns + env vars
|
|
439
|
+
- v0.26.1: **Automatic US sync restored!** `SKIP_US_SYNC` removed → Smart throttle (60s window) → fs.writeFile() validated safe
|
|
440
|
+
- v0.25.2: `SKIP_EXTERNAL_SYNC` guard at LivingDocsSync layer → prevents recursion cascade
|
|
441
|
+
- v0.25.1: TodoWrite crash → emergency `SKIP_US_SYNC=true` → manual `/specweave:sync-progress` (temporary fix)
|
|
442
|
+
- v0.25.0: 6→4 hooks (33% reduction)
|
|
443
|
+
- v0.24.4: State-based filtering (95% overhead reduction)
|
|
444
|
+
- v0.26.1: PROJECT_ROOT before RECURSION_GUARD_FILE (order bug fix)
|
|
1222
445
|
|
|
1223
446
|
---
|
|
1224
447
|
|
|
@@ -1233,470 +456,113 @@ unset SPECWEAVE_DISABLE_HOOKS
|
|
|
1233
456
|
/specweave:done 0002 # Close (validates)
|
|
1234
457
|
/specweave:validate 0001 # Validate
|
|
1235
458
|
/specweave:qa 0001 # Quality check
|
|
1236
|
-
/specweave:pause/resume/abandon # State management
|
|
1237
459
|
|
|
1238
460
|
# Feature deletion
|
|
1239
|
-
specweave delete-feature FS-042 --dry-run
|
|
1240
|
-
specweave delete-feature FS-042
|
|
1241
|
-
specweave delete-feature FS-042 --force
|
|
1242
|
-
specweave delete-feature FS-042 --no-git # Skip git operations
|
|
1243
|
-
specweave delete-feature FS-042 --no-github # Skip GitHub issue cleanup
|
|
1244
|
-
specweave delete-feature FS-042 --yes # Skip confirmations (except elevated)
|
|
1245
|
-
```
|
|
1246
|
-
|
|
1247
|
-
**Local setup**:
|
|
1248
|
-
```bash
|
|
1249
|
-
git clone https://github.com/YOUR_USERNAME/specweave.git
|
|
1250
|
-
cd specweave && npm install && npm run rebuild
|
|
1251
|
-
bash scripts/install-git-hooks.sh
|
|
1252
|
-
|
|
1253
|
-
# Push changes to GitHub → Claude Code auto-updates marketplace (5-10s)
|
|
1254
|
-
# For fork-based testing: claude plugin marketplace add github:YOUR_USERNAME/specweave
|
|
461
|
+
specweave delete-feature FS-042 --dry-run # Preview
|
|
462
|
+
specweave delete-feature FS-042 # Safe delete (requires confirmation)
|
|
463
|
+
specweave delete-feature FS-042 --force # Force (orphans active increments)
|
|
1255
464
|
```
|
|
1256
465
|
|
|
1257
466
|
---
|
|
1258
467
|
|
|
1259
468
|
## Build & Test
|
|
1260
469
|
|
|
1261
|
-
**Build**:
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
npm run build # Compile TS + copy deps
|
|
1265
|
-
```
|
|
1266
|
-
|
|
1267
|
-
**Architecture**: `tsc` → `dist/src/`, esbuild → plugin hooks, copy deps → `plugins/*/lib/vendor/`
|
|
1268
|
-
|
|
1269
|
-
**CRITICAL**: Always `.js` extensions (`import { foo } from './bar.js'`)
|
|
470
|
+
**Build**: `npm run rebuild` (clean + build), `npm run build`
|
|
471
|
+
**Architecture**: `tsc` → `dist/src/`, esbuild → hooks, copy deps → `plugins/*/lib/vendor/`
|
|
472
|
+
**CRITICAL**: Always `.js` extensions in imports
|
|
1270
473
|
|
|
1271
474
|
**Test**:
|
|
1272
475
|
```bash
|
|
1273
|
-
npm test
|
|
1274
|
-
npm run test:unit
|
|
1275
|
-
npm run test:integration
|
|
1276
|
-
npm run test:all
|
|
1277
|
-
npm run test:coverage
|
|
476
|
+
npm test # Smoke
|
|
477
|
+
npm run test:unit # Unit
|
|
478
|
+
npm run test:integration # Integration
|
|
479
|
+
npm run test:all # All
|
|
480
|
+
npm run test:coverage # Coverage (80%+ required)
|
|
1278
481
|
```
|
|
1279
482
|
|
|
1280
|
-
**Test rules**:
|
|
1281
|
-
- Use `vi.fn()` (NOT `jest.fn()`)
|
|
1282
|
-
- Use `os.tmpdir()` (NOT `process.cwd()`)
|
|
1283
|
-
- ALL tests = `.test.ts` (NEVER `.spec.ts`)
|
|
1284
|
-
- Use `createIsolatedTestDir()` helper
|
|
483
|
+
**Test rules**: `vi.fn()` (NOT `jest.fn()`), `os.tmpdir()` (NOT `process.cwd()`), `.test.ts` (NOT `.spec.ts`)
|
|
1285
484
|
|
|
1286
485
|
---
|
|
1287
486
|
|
|
1288
|
-
## Configuration Management
|
|
487
|
+
## Configuration Management
|
|
1289
488
|
|
|
1290
489
|
**Secrets** (.env, gitignored) vs **Config** (.specweave/config.json, committed)
|
|
1291
490
|
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
const config = await configManager.read();
|
|
1297
|
-
await configManager.update({ issueTracker: { provider: 'jira', domain: 'example.atlassian.net' }});
|
|
1298
|
-
```
|
|
1299
|
-
|
|
1300
|
-
**What goes where**:
|
|
1301
|
-
|
|
1302
|
-
| Type | Location | Example | Committed? |
|
|
1303
|
-
|------|----------|---------|------------|
|
|
1304
|
-
| Tokens/Emails | `.env` | `JIRA_API_TOKEN=xyz` | ❌ |
|
|
1305
|
-
| Domains/Strategies | `config.json` | `"domain": "example.atlassian.net"` | ✅ |
|
|
1306
|
-
|
|
1307
|
-
**Migration**: `node -e "require('./dist/src/cli/commands/migrate-config.js').migrateConfig({ dryRun: true })"`
|
|
1308
|
-
|
|
1309
|
-
**See**: ADR-0050, `src/core/config/config-manager.ts`
|
|
491
|
+
| Type | Location | Committed? |
|
|
492
|
+
|------|----------|------------|
|
|
493
|
+
| Tokens/Emails | `.env` | ❌ |
|
|
494
|
+
| Domains/Strategies | `config.json` | ✅ |
|
|
1310
495
|
|
|
1311
496
|
---
|
|
1312
497
|
|
|
1313
|
-
## Cache Management
|
|
1314
|
-
|
|
1315
|
-
**Smart Caching with 24-Hour TTL**: Reduces API calls by 90% during init and sync operations.
|
|
1316
|
-
|
|
1317
|
-
### Cache Architecture
|
|
1318
|
-
|
|
1319
|
-
**Location**: `.specweave/cache/`
|
|
1320
|
-
**TTL**: 24 hours (configurable)
|
|
1321
|
-
**Format**: JSON with timestamps
|
|
1322
|
-
|
|
1323
|
-
### Cached Data
|
|
498
|
+
## Cache Management
|
|
1324
499
|
|
|
1325
|
-
|
|
1326
|
-
|-----------|------|----------|
|
|
1327
|
-
| `jira-projects-{domain}` | Project list | JIRA init (auto-discovery) |
|
|
1328
|
-
| `ado-config` | Org/project/teams | ADO init (manual entry) |
|
|
1329
|
-
| `jira-{PROJECT}-deps` | Boards, components, versions | On-demand dependency loading |
|
|
1330
|
-
| `ado-{PROJECT}-deps` | Area paths, teams | ADO dependency loading |
|
|
500
|
+
**Location**: `.specweave/cache/`, **TTL**: 24 hours
|
|
1331
501
|
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
**Automatic caching** (during init):
|
|
1335
|
-
- JIRA: `promptJiraCredentials()` caches selected projects
|
|
1336
|
-
- ADO: `promptAzureDevOpsCredentials()` caches org/project config
|
|
1337
|
-
|
|
1338
|
-
**Manual cache management**:
|
|
1339
|
-
```bash
|
|
1340
|
-
# Refresh cache (bypass TTL)
|
|
1341
|
-
/specweave-jira:refresh-cache --all
|
|
1342
|
-
/specweave-ado:refresh-cache --all
|
|
1343
|
-
|
|
1344
|
-
# Clean old caches
|
|
1345
|
-
/specweave:cleanup-cache --older-than 7d
|
|
1346
|
-
|
|
1347
|
-
# View cache statistics
|
|
1348
|
-
/specweave:cache-stats
|
|
1349
|
-
```
|
|
502
|
+
**Cached**: JIRA projects, ADO config, boards, components (NOT tokens/PATs)
|
|
1350
503
|
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
**Never cached**: API tokens, PATs, passwords (secrets stay in `.env`)
|
|
1354
|
-
**Always cached**: Non-sensitive config (domains, project keys, org names)
|
|
1355
|
-
**Atomic writes**: Temp file → rename pattern prevents corruption
|
|
1356
|
-
**Auto-recovery**: Corrupted cache auto-deleted, fallback to API
|
|
1357
|
-
|
|
1358
|
-
### Integration
|
|
1359
|
-
|
|
1360
|
-
**CLI Helpers**:
|
|
1361
|
-
- `src/cli/helpers/issue-tracker/jira.ts`: JIRA project caching
|
|
1362
|
-
- `src/cli/helpers/issue-tracker/ado.ts`: ADO config caching
|
|
1363
|
-
|
|
1364
|
-
**Core Module**:
|
|
1365
|
-
- `src/core/cache/cache-manager.ts`: TTL validation, atomic writes, corruption handling
|
|
1366
|
-
|
|
1367
|
-
**Tests**:
|
|
1368
|
-
- `tests/integration/cli/helpers/cache-integration.test.ts`: 85%+ coverage
|
|
1369
|
-
|
|
1370
|
-
**See**: ADR-0051 (Smart Caching with TTL), `src/core/cache/rate-limit-checker.ts`
|
|
504
|
+
**Manual**: `/specweave-jira:refresh-cache --all`, `/specweave:cleanup-cache --older-than 7d`
|
|
1371
505
|
|
|
1372
506
|
---
|
|
1373
507
|
|
|
1374
|
-
##
|
|
1375
|
-
|
|
1376
|
-
- **Skills not activating**: Check YAML frontmatter, restart Claude Code
|
|
1377
|
-
- **Commands not working**: Verify plugin installed, restart
|
|
1378
|
-
- **Tests failing**: `npm run rebuild`
|
|
1379
|
-
- **Root polluted**: Move to `.specweave/increments/####/reports/`
|
|
1380
|
-
- **Hooks failing**: Push to GitHub (auto-updates 5-10s)
|
|
1381
|
-
|
|
1382
|
-
---
|
|
1383
|
-
|
|
1384
|
-
## Comprehensive Progress Sync (v0.25.0+)
|
|
1385
|
-
|
|
1386
|
-
**Command**: `/specweave:sync-progress`
|
|
1387
|
-
|
|
1388
|
-
**Purpose**: Single-button multi-system synchronization. Orchestrates complete flow from task completion → living docs → external tools (GitHub/JIRA/ADO).
|
|
1389
|
-
|
|
1390
|
-
### What It Does
|
|
1391
|
-
|
|
1392
|
-
**Comprehensive Sync Flow**:
|
|
1393
|
-
```
|
|
1394
|
-
tasks.md (source of truth)
|
|
1395
|
-
↓
|
|
1396
|
-
spec.md ACs (marked complete)
|
|
1397
|
-
↓
|
|
1398
|
-
Living docs (user stories updated)
|
|
1399
|
-
↓
|
|
1400
|
-
External tools (GitHub/JIRA/ADO synced)
|
|
1401
|
-
↓
|
|
1402
|
-
Status line cache (updated display)
|
|
1403
|
-
```
|
|
1404
|
-
|
|
1405
|
-
**One command replaces 4 manual steps**:
|
|
1406
|
-
```bash
|
|
1407
|
-
# OLD: Manual multi-step sync (error-prone)
|
|
1408
|
-
/specweave:sync-acs 0053
|
|
1409
|
-
/specweave:sync-specs 0053
|
|
1410
|
-
/specweave-github:sync 0053
|
|
1411
|
-
/specweave:update-status
|
|
1412
|
-
|
|
1413
|
-
# NEW: Single comprehensive sync ✅
|
|
1414
|
-
/specweave:sync-progress 0053
|
|
1415
|
-
```
|
|
1416
|
-
|
|
1417
|
-
### Usage
|
|
1418
|
-
|
|
1419
|
-
```bash
|
|
1420
|
-
# Auto-detect active increment
|
|
1421
|
-
/specweave:sync-progress
|
|
1422
|
-
|
|
1423
|
-
# Explicit increment ID
|
|
1424
|
-
/specweave:sync-progress 0053
|
|
1425
|
-
|
|
1426
|
-
# Dry-run mode (preview without executing)
|
|
1427
|
-
/specweave:sync-progress 0053 --dry-run
|
|
1428
|
-
|
|
1429
|
-
# Skip external tools (local-only sync)
|
|
1430
|
-
/specweave:sync-progress 0053 --no-github --no-jira --no-ado
|
|
1431
|
-
```
|
|
1432
|
-
|
|
1433
|
-
### When to Use
|
|
1434
|
-
|
|
1435
|
-
**✅ Use /specweave:sync-progress when**:
|
|
1436
|
-
1. After completing tasks in tasks.md
|
|
1437
|
-
2. Before closing increment (`/specweave:done`)
|
|
1438
|
-
3. Want to update status line with latest progress
|
|
1439
|
-
4. Need to sync to external tools (GitHub/JIRA/ADO)
|
|
1440
|
-
5. After bulk task completion
|
|
1441
|
-
|
|
1442
|
-
**❌ Don't use when**:
|
|
1443
|
-
1. Only need to sync ACs → Use `/specweave:sync-acs`
|
|
1444
|
-
2. Only need to sync docs → Use `/specweave:sync-specs`
|
|
1445
|
-
3. Only need to sync GitHub → Use `/specweave-github:sync`
|
|
1446
|
-
|
|
1447
|
-
### Multi-Phase Orchestration
|
|
1448
|
-
|
|
1449
|
-
**Phase 1: Tasks → ACs (spec.md)**
|
|
1450
|
-
- Reads completed tasks from tasks.md
|
|
1451
|
-
- Finds linked ACs via `**Satisfies ACs**` field
|
|
1452
|
-
- Marks ACs as complete: `[ ]` → `[x]`
|
|
1453
|
-
- Updates metadata.json with AC count
|
|
1454
|
-
|
|
1455
|
-
**Phase 2: Spec → Living Docs**
|
|
1456
|
-
- Syncs spec.md to living docs structure
|
|
1457
|
-
- Updates user story completion status
|
|
1458
|
-
- Generates/updates feature ID if needed
|
|
1459
|
-
|
|
1460
|
-
**Phase 3: Living Docs → External Tools**
|
|
1461
|
-
- **GitHub**: Closes completed user story issues, updates epic checklist
|
|
1462
|
-
- **JIRA**: Updates story status, transitions workflow
|
|
1463
|
-
- **Azure DevOps**: Updates work item state, adds comments
|
|
1464
|
-
|
|
1465
|
-
**Phase 4: Status Line Cache**
|
|
1466
|
-
- Updates status line with latest completion %
|
|
1467
|
-
|
|
1468
|
-
### Flags
|
|
1469
|
-
|
|
1470
|
-
| Flag | Purpose | Example |
|
|
1471
|
-
|------|---------|---------|
|
|
1472
|
-
| `--dry-run` | Preview without executing | `--dry-run` |
|
|
1473
|
-
| `--no-github` | Skip GitHub sync | `--no-github` |
|
|
1474
|
-
| `--no-jira` | Skip JIRA sync | `--no-jira` |
|
|
1475
|
-
| `--no-ado` | Skip Azure DevOps sync | `--no-ado` |
|
|
1476
|
-
| `--force` | Force sync even if validation fails | `--force` |
|
|
1477
|
-
|
|
1478
|
-
### Error Handling
|
|
1479
|
-
|
|
1480
|
-
**Graceful Degradation**:
|
|
1481
|
-
- **Critical errors** (AC sync, docs sync): Abort entire sync
|
|
1482
|
-
- **Non-critical errors** (GitHub, JIRA, ADO): Log warning, continue
|
|
1483
|
-
|
|
1484
|
-
**Philosophy**: Core sync (tasks → docs) must succeed. External tool sync is best-effort.
|
|
1485
|
-
|
|
1486
|
-
### Example Workflow
|
|
1487
|
-
|
|
1488
|
-
**Typical increment workflow with progress sync**:
|
|
1489
|
-
|
|
1490
|
-
```bash
|
|
1491
|
-
# 1. Plan increment
|
|
1492
|
-
/specweave:increment "Safe feature deletion"
|
|
1493
|
-
|
|
1494
|
-
# 2. Execute tasks
|
|
1495
|
-
/specweave:do
|
|
1496
|
-
|
|
1497
|
-
# [Complete 5 tasks...]
|
|
1498
|
-
|
|
1499
|
-
# 3. Sync progress after batch
|
|
1500
|
-
/specweave:sync-progress
|
|
1501
|
-
|
|
1502
|
-
# [Complete remaining 32 tasks...]
|
|
1503
|
-
|
|
1504
|
-
# 4. Final sync before closure
|
|
1505
|
-
/specweave:sync-progress 0053
|
|
1506
|
-
|
|
1507
|
-
# 5. Validate quality
|
|
1508
|
-
/specweave:validate 0053 --quality
|
|
1509
|
-
|
|
1510
|
-
# 6. Close increment
|
|
1511
|
-
/specweave:done 0053
|
|
1512
|
-
```
|
|
1513
|
-
|
|
1514
|
-
### External Tool Auto-Detection
|
|
508
|
+
## Comprehensive Progress Sync
|
|
1515
509
|
|
|
1516
|
-
**
|
|
1517
|
-
- GitHub: `"provider": "github"`
|
|
1518
|
-
- JIRA: `"provider": "jira"`
|
|
1519
|
-
- Azure DevOps: `"provider": "azure-devops"`
|
|
510
|
+
**Command**: `/specweave:sync-progress [increment]`
|
|
1520
511
|
|
|
1521
|
-
**
|
|
1522
|
-
```
|
|
1523
|
-
✅ GitHub integration detected → Will sync
|
|
1524
|
-
ℹ️ No JIRA integration → Skip
|
|
1525
|
-
ℹ️ No ADO integration → Skip
|
|
1526
|
-
```
|
|
512
|
+
**Flow**: tasks.md → spec.md ACs → living docs → external tools (GitHub/JIRA/ADO) → status line
|
|
1527
513
|
|
|
1528
|
-
|
|
514
|
+
**Replaces 4 commands**: `/specweave:sync-acs` + `/specweave:sync-specs` + `/specweave-github:sync` + `/specweave:update-status`
|
|
1529
515
|
|
|
1530
|
-
**
|
|
1531
|
-
```bash
|
|
1532
|
-
# Provide increment ID explicitly
|
|
1533
|
-
/specweave:sync-progress 0053
|
|
1534
|
-
```
|
|
516
|
+
**Flags**: `--dry-run`, `--no-github`, `--no-jira`, `--no-ado`, `--force`
|
|
1535
517
|
|
|
1536
|
-
**
|
|
1537
|
-
```bash
|
|
1538
|
-
# Embed ACs from living docs into spec.md
|
|
1539
|
-
/specweave:embed-acs 0053
|
|
1540
|
-
|
|
1541
|
-
# Then retry sync
|
|
1542
|
-
/specweave:sync-progress 0053
|
|
1543
|
-
```
|
|
1544
|
-
|
|
1545
|
-
**"GitHub rate limit exceeded"** (non-critical):
|
|
1546
|
-
- Docs are synced successfully
|
|
1547
|
-
- Retry GitHub sync later when rate limit resets:
|
|
1548
|
-
```bash
|
|
1549
|
-
/specweave-github:sync 0053
|
|
1550
|
-
```
|
|
1551
|
-
|
|
1552
|
-
**See**:
|
|
1553
|
-
- Skill: `progress-sync` (comprehensive guide)
|
|
1554
|
-
- Increment 0053 (added in this increment)
|
|
518
|
+
**When to use**: After completing tasks, before closing increment, bulk completion
|
|
1555
519
|
|
|
1556
520
|
---
|
|
1557
521
|
|
|
1558
|
-
## Safe Feature Deletion
|
|
522
|
+
## Safe Feature Deletion
|
|
1559
523
|
|
|
1560
524
|
**Command**: `specweave delete-feature <feature-id>`
|
|
1561
525
|
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
526
|
+
**4-Tier Validation**: Feature detection → active increment check → git status → GitHub scan
|
|
527
|
+
**3-Phase Commit**: Validation → staging (reversible) → commit (irreversible)
|
|
528
|
+
**Multi-Gate Confirmation**: Primary (y/N) → elevated (type "delete" in force mode) → GitHub (separate)
|
|
1565
529
|
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
specweave delete-feature FS-042 --dry-run
|
|
530
|
+
**Deletes**: Living docs FEATURE.md, user stories, README, GitHub issues
|
|
531
|
+
**NOT deleted**: Increments (metadata.json updated if orphaned)
|
|
1569
532
|
|
|
1570
|
-
|
|
1571
|
-
specweave delete-feature FS-042
|
|
533
|
+
**Modes**: Safe (default, blocks active increments), Force (`--force`, orphans increments), Dry-run (`--dry-run`, preview)
|
|
1572
534
|
|
|
1573
|
-
|
|
1574
|
-
specweave delete-feature FS-042 --force
|
|
535
|
+
**Audit**: `.specweave/logs/feature-deletions.log` (JSON Lines, includes commit SHA)
|
|
1575
536
|
|
|
1576
|
-
|
|
1577
|
-
specweave delete-feature FS-042 --no-git
|
|
537
|
+
---
|
|
1578
538
|
|
|
1579
|
-
|
|
1580
|
-
specweave delete-feature FS-042 --no-github
|
|
539
|
+
## Project Structure
|
|
1581
540
|
|
|
1582
|
-
|
|
1583
|
-
|
|
541
|
+
```
|
|
542
|
+
src/ # TypeScript → dist/
|
|
543
|
+
plugins/ # Skills, agents, commands, hooks
|
|
544
|
+
├── specweave/ # Core
|
|
545
|
+
└── specweave-*/ # Optional
|
|
546
|
+
.specweave/ # Increments, docs, logs
|
|
1584
547
|
```
|
|
1585
548
|
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
**4-Tier Validation**:
|
|
1589
|
-
1. **Feature Detection**: Scans living docs and user stories
|
|
1590
|
-
2. **Active Increment Check**: Blocks deletion if active increments reference feature (safe mode)
|
|
1591
|
-
3. **Git Status Check**: Ensures clean working directory
|
|
1592
|
-
4. **GitHub Issue Scan**: Finds related issues for cleanup
|
|
1593
|
-
|
|
1594
|
-
**3-Phase Commit Pattern**:
|
|
1595
|
-
1. **Validation Phase**: All safety checks
|
|
1596
|
-
2. **Staging Phase**: Reversible (file backup, git staging)
|
|
1597
|
-
3. **Commit Phase**: Irreversible (git commit, GitHub cleanup, audit log)
|
|
1598
|
-
|
|
1599
|
-
**Multi-Gate Confirmation**:
|
|
1600
|
-
- Primary Confirmation: y/N prompt for all deletions
|
|
1601
|
-
- Elevated Confirmation: Type "delete" for force mode (orphans active increments)
|
|
1602
|
-
- GitHub Confirmation: Separate prompt for closing GitHub issues
|
|
1603
|
-
|
|
1604
|
-
### What Gets Deleted
|
|
1605
|
-
|
|
1606
|
-
✅ Living docs: `.specweave/docs/internal/specs/_features/FS-XXX/FEATURE.md`
|
|
1607
|
-
✅ User stories: `.specweave/docs/internal/specs/{project}/FS-XXX/us-*.md`
|
|
1608
|
-
✅ README files: `.specweave/docs/internal/specs/{project}/FS-XXX/README.md`
|
|
1609
|
-
✅ GitHub issues: Issues matching `[FS-XXX][US-YYY]` pattern (optional)
|
|
1610
|
-
|
|
1611
|
-
❌ NOT deleted: Increments (only metadata.json updated if orphaned)
|
|
1612
|
-
|
|
1613
|
-
### Modes
|
|
1614
|
-
|
|
1615
|
-
**Safe Mode (default)**:
|
|
1616
|
-
- Blocks deletion if active increments reference feature
|
|
1617
|
-
- Requires clean git working directory
|
|
1618
|
-
- Requires explicit confirmation
|
|
1619
|
-
|
|
1620
|
-
**Force Mode (`--force`)**:
|
|
1621
|
-
- Allows deletion with active increments
|
|
1622
|
-
- Updates orphaned increment metadata.json (removes feature_id)
|
|
1623
|
-
- Requires elevated confirmation (type "delete")
|
|
1624
|
-
|
|
1625
|
-
**Dry-Run Mode (`--dry-run`)**:
|
|
1626
|
-
- Preview deletion without executing
|
|
1627
|
-
- Shows all files to be deleted
|
|
1628
|
-
- Shows git operations
|
|
1629
|
-
- Shows GitHub issues to be closed
|
|
549
|
+
---
|
|
1630
550
|
|
|
1631
|
-
|
|
551
|
+
## Plugin Hook Registration
|
|
1632
552
|
|
|
1633
|
-
|
|
553
|
+
**Valid events** (10): PostToolUse, PreToolUse, PermissionRequest, Notification, UserPromptSubmit, Stop, SubagentStop, PreCompact, SessionStart, SessionEnd
|
|
1634
554
|
|
|
1635
555
|
```json
|
|
1636
556
|
{
|
|
1637
|
-
"
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
"githubIssuesClosed": 3,
|
|
1644
|
-
"orphanedIncrements": [],
|
|
1645
|
-
"status": "success"
|
|
557
|
+
"hooks": {
|
|
558
|
+
"PostToolUse": [{
|
|
559
|
+
"matcher": "TodoWrite",
|
|
560
|
+
"hooks": [{ "type": "command", "command": "${CLAUDE_PLUGIN_ROOT}/hooks/post-task-completion.sh", "timeout": 10 }]
|
|
561
|
+
}]
|
|
562
|
+
}
|
|
1646
563
|
}
|
|
1647
564
|
```
|
|
1648
565
|
|
|
1649
|
-
**Log rotation**: Automatically rotates at 10MB threshold.
|
|
1650
|
-
|
|
1651
|
-
### Error Handling
|
|
1652
|
-
|
|
1653
|
-
**Non-blocking errors** (logged as warnings):
|
|
1654
|
-
- GitHub API rate limits (exponential backoff retry)
|
|
1655
|
-
- GitHub issue cleanup failures
|
|
1656
|
-
- Audit log write failures
|
|
1657
|
-
|
|
1658
|
-
**Blocking errors** (prevent deletion):
|
|
1659
|
-
- Feature not found
|
|
1660
|
-
- Active increments in safe mode
|
|
1661
|
-
- Git working directory not clean (without `--no-git`)
|
|
1662
|
-
- Invalid feature ID format (must be FS-XXX)
|
|
1663
|
-
|
|
1664
|
-
### Examples
|
|
1665
|
-
|
|
1666
|
-
```bash
|
|
1667
|
-
# Recommended workflow
|
|
1668
|
-
specweave delete-feature FS-042 --dry-run # Preview
|
|
1669
|
-
specweave delete-feature FS-042 # Execute (with confirmation)
|
|
1670
|
-
|
|
1671
|
-
# Force delete feature with active increment 0050
|
|
1672
|
-
specweave delete-feature FS-042 --force # Requires typing "delete"
|
|
1673
|
-
|
|
1674
|
-
# Delete without git commit (manual git workflow)
|
|
1675
|
-
specweave delete-feature FS-042 --no-git
|
|
1676
|
-
|
|
1677
|
-
# Delete with auto-yes (CI/CD pipelines)
|
|
1678
|
-
specweave delete-feature FS-042 --yes --dry-run # Still shows preview
|
|
1679
|
-
```
|
|
1680
|
-
|
|
1681
|
-
### Important Notes
|
|
1682
|
-
|
|
1683
|
-
**GitHub Integration**:
|
|
1684
|
-
- Owner/repo auto-detected from `git remote get-url origin`
|
|
1685
|
-
- If no GitHub remote → GitHub cleanup silently skipped (non-blocking)
|
|
1686
|
-
- Pattern detection: `https://github.com/owner/repo.git` or `git@github.com:owner/repo.git`
|
|
1687
|
-
|
|
1688
|
-
**No Undo**:
|
|
1689
|
-
- Deletion is permanent (files deleted from filesystem)
|
|
1690
|
-
- Recovery: `git log --all --full-history -- path/to/deleted/file` → `git checkout <commit> -- path`
|
|
1691
|
-
- Audit log: `.specweave/logs/feature-deletions.log` (includes commit SHA)
|
|
1692
|
-
|
|
1693
|
-
**Force Mode Risk**:
|
|
1694
|
-
- Orphaned increments lose `feature_id` in metadata.json
|
|
1695
|
-
- Breaking change: `/specweave:sync-specs` won't sync orphaned increments
|
|
1696
|
-
- Recovery: Manually restore `feature_id` in metadata.json
|
|
1697
|
-
|
|
1698
|
-
**See**: Increment 0053-safe-feature-deletion for implementation details.
|
|
1699
|
-
|
|
1700
566
|
---
|
|
1701
567
|
|
|
1702
568
|
## Quick Reference
|
|
@@ -1708,11 +574,24 @@ specweave delete-feature FS-042 --yes --dry-run # Still shows preview
|
|
|
1708
574
|
**Structure**: `src/` (TS), `plugins/` (components), `.specweave/` (data), `tests/` (tests)
|
|
1709
575
|
|
|
1710
576
|
**Remember**:
|
|
1711
|
-
1. Push → GitHub →
|
|
1712
|
-
2. Keep root clean
|
|
577
|
+
1. Push → GitHub → auto-updates (5-10s)
|
|
578
|
+
2. Keep root clean (reports in increment subfolders)
|
|
1713
579
|
3. Test before commit
|
|
1714
580
|
4. NEVER delete `.specweave/`
|
|
1715
581
|
5. Use `/specweave:done` (not manual edits)
|
|
582
|
+
6. ALWAYS use GitHub mode for marketplace refresh (unless actively developing uncommitted changes)
|
|
583
|
+
7. tasks.md + spec.md are SOURCE OF TRUTH (not internal TODO)
|
|
1716
584
|
|
|
1717
585
|
**See**: `.github/CONTRIBUTING.md`, https://spec-weave.com
|
|
1718
586
|
|
|
587
|
+
---
|
|
588
|
+
|
|
589
|
+
## References
|
|
590
|
+
|
|
591
|
+
**ADRs**: 0032 (GitHub Hierarchy), 0050 (Config Management), 0051 (Caching), 0060 (Hook Optimization), 0061 (No Increment References), 0064 (AC Presence), 0069 (Git Provider Abstraction), 0070 (Hook Consolidation), 0129 (US Sync Guard Rails), 0132 (No Early Returns)
|
|
592
|
+
|
|
593
|
+
**Emergency Procedures**: `.specweave/docs/internal/emergency-procedures/HOOK-CRASH-RECOVERY.md`, `TODOWRITE-CRASH-RECOVERY.md`, `AC-SYNC-CONFLICT-FIX-2025-11-24.md`
|
|
594
|
+
|
|
595
|
+
**Incident Reports**: See increment 0044 (TODO desync), 0047 (GitHub sync removal), 0050 (Hook crashes, AC presence, GitHub issues), 0051 (PROJECT_ROOT order), 0053 (Safe deletion, TodoWrite crash, AC parser, GitHub multi-repo)
|
|
596
|
+
|
|
597
|
+
**Validation Scripts**: `validate-marketplace-plugins.sh`, `validate-plugin-directories.sh`, `validate-hook-variable-order.sh`, `cleanup-duplicate-github-issues.sh`
|