specweave 0.26.10 → 0.26.11
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 +95 -520
- package/dist/src/cli/commands/init.js +2 -2
- package/dist/src/cli/commands/init.js.map +1 -1
- package/package.json +1 -1
- package/plugins/specweave-ado/lib/ado-multi-project-sync.js +0 -1
- package/plugins/specweave-jira/lib/enhanced-jira-sync.js +3 -3
- package/plugins/specweave/hooks/docs-changed.sh.backup +0 -79
- package/plugins/specweave/hooks/human-input-required.sh.backup +0 -75
- package/plugins/specweave/hooks/post-first-increment.sh.backup +0 -61
- package/plugins/specweave/hooks/post-increment-change.sh.backup +0 -98
- package/plugins/specweave/hooks/post-increment-completion.sh.backup +0 -231
- package/plugins/specweave/hooks/post-increment-planning.sh.backup +0 -1048
- package/plugins/specweave/hooks/post-increment-status-change.sh.backup +0 -147
- package/plugins/specweave/hooks/post-spec-update.sh.backup +0 -158
- package/plugins/specweave/hooks/post-user-story-complete.sh.backup +0 -179
- package/plugins/specweave/hooks/pre-command-deduplication.sh.backup +0 -83
- package/plugins/specweave/hooks/pre-implementation.sh.backup +0 -67
- package/plugins/specweave/hooks/pre-task-completion.sh.backup +0 -194
- package/plugins/specweave/hooks/pre-tool-use.sh.backup +0 -133
- package/plugins/specweave/hooks/user-prompt-submit.sh.backup +0 -386
- package/plugins/specweave-ado/hooks/post-living-docs-update.sh.backup +0 -353
- package/plugins/specweave-ado/hooks/post-task-completion.sh.backup +0 -172
- package/plugins/specweave-ado/lib/enhanced-ado-sync.js +0 -170
- package/plugins/specweave-github/hooks/.specweave/logs/hooks-debug.log +0 -1080
- package/plugins/specweave-github/hooks/post-task-completion.sh.backup +0 -258
- package/plugins/specweave-jira/hooks/post-task-completion.sh.backup +0 -172
- package/plugins/specweave-release/hooks/.specweave/logs/dora-tracking.log +0 -981
- package/plugins/specweave-release/hooks/post-task-completion.sh.backup +0 -110
package/CLAUDE.md
CHANGED
|
@@ -2,242 +2,93 @@
|
|
|
2
2
|
|
|
3
3
|
**Project**: SpecWeave - Spec-Driven Development Framework
|
|
4
4
|
**Type**: TypeScript CLI (NPM Package)
|
|
5
|
-
**Repository**: https://github.com/anton-abyzov/specweave
|
|
6
5
|
|
|
7
6
|
For **contributors to SpecWeave itself** (not users).
|
|
8
7
|
|
|
9
8
|
---
|
|
10
9
|
|
|
11
|
-
##
|
|
10
|
+
## CRITICAL SAFETY RULES
|
|
12
11
|
|
|
13
|
-
###
|
|
12
|
+
### 1. Context Management (CRASH PREVENTION!)
|
|
14
13
|
|
|
15
|
-
**
|
|
16
|
-
|
|
17
|
-
**Context Management**: Active increment with 10+ tasks + editing unrelated 2000+ line file = crash risk (context overflow). Pause first: `/specweave:pause XXXX` → edit → `/specweave:resume XXXX`. See ADR-0133, Section 15.
|
|
18
|
-
|
|
19
|
-
```bash
|
|
20
|
-
# ❌ WRONG: node -e "require('./dist/file.js')" (before build)
|
|
21
|
-
# ✅ CORRECT: npm run rebuild && node -e "require('./dist/file.js')"
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
---
|
|
25
|
-
|
|
26
|
-
## 1. Development Setup
|
|
27
|
-
|
|
28
|
-
**Standard Workflow**:
|
|
29
|
-
```bash
|
|
30
|
-
git clone https://github.com/YOUR_USERNAME/specweave.git
|
|
31
|
-
cd specweave && npm install && npm run rebuild
|
|
32
|
-
|
|
33
|
-
# Development Cycle
|
|
34
|
-
npm run rebuild && npm test
|
|
35
|
-
git add . && git commit -m "feat: feature" && git push origin develop
|
|
36
|
-
# Wait 5-10s → Claude Code auto-updates marketplace
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
**Testing Unpushed**: Temp branch → push → test → delete, OR `claude plugin marketplace add github:YOUR_USERNAME/specweave`
|
|
40
|
-
|
|
41
|
-
---
|
|
42
|
-
|
|
43
|
-
### 1a. Marketplace Refresh
|
|
44
|
-
|
|
45
|
-
```bash
|
|
46
|
-
bash scripts/refresh-marketplace.sh # GitHub (default, ALWAYS use)
|
|
47
|
-
bash scripts/refresh-marketplace.sh --local # Local dev only (filesystem coupling risks)
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
**Use GitHub mode**: Proper install path, stable source, no hook coupling (~30s)
|
|
51
|
-
**Verify**: `jq -r '.specweave.source' ~/.claude/plugins/known_marketplaces.json` → should be `"github"`
|
|
52
|
-
|
|
53
|
-
**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/`).
|
|
54
|
-
|
|
55
|
-
---
|
|
56
|
-
|
|
57
|
-
### 1b. NPM Release
|
|
14
|
+
**Active increment (10+ tasks) + large file edit (2000+ lines) = CRASH**
|
|
58
15
|
|
|
59
16
|
```bash
|
|
60
|
-
|
|
61
|
-
/specweave
|
|
17
|
+
# Before editing large files outside increment:
|
|
18
|
+
/specweave:pause XXXX → edit → /specweave:resume XXXX
|
|
19
|
+
# OR close completed increments: /specweave:done XXXX
|
|
62
20
|
```
|
|
63
21
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
## 2. Folder Structure Rules
|
|
67
|
-
|
|
68
|
-
**At `.specweave/increments/` root - ONLY**:
|
|
69
|
-
1. `####-increment-name/` folders
|
|
70
|
-
2. `_archive/` folder
|
|
71
|
-
3. `README.md` (optional)
|
|
72
|
-
|
|
73
|
-
**Inside increment folders - ONLY at root**: `spec.md`, `plan.md`, `tasks.md`, `metadata.json`
|
|
74
|
-
|
|
75
|
-
**Everything else → subfolders**:
|
|
76
|
-
- `reports/` - Completion reports, investigation findings, final summaries
|
|
77
|
-
- `scripts/` - Helper scripts, automation, migration tools
|
|
78
|
-
- `logs/` - Debug logs, performance logs, execution traces
|
|
79
|
-
- `backups/` - Backup files, .backup versions
|
|
80
|
-
- `docs/` - Additional documentation, diagrams, references
|
|
81
|
-
|
|
82
|
-
**Examples**:
|
|
83
|
-
```
|
|
84
|
-
0055-feature/
|
|
85
|
-
├── spec.md ✅ Required
|
|
86
|
-
├── plan.md ✅ Required
|
|
87
|
-
├── tasks.md ✅ Required
|
|
88
|
-
├── metadata.json ✅ Required
|
|
89
|
-
├── reports/ ✅ Good organization
|
|
90
|
-
│ ├── completion-summary.md
|
|
91
|
-
│ └── FINAL-REPORT.md
|
|
92
|
-
├── scripts/ ✅ Good organization
|
|
93
|
-
│ └── migration.sh
|
|
94
|
-
└── backups/ ✅ Good organization
|
|
95
|
-
└── SKILL.md.backup
|
|
96
|
-
```
|
|
97
|
-
|
|
98
|
-
```bash
|
|
99
|
-
# Validation (should output NOTHING):
|
|
100
|
-
ls -1 .specweave/increments/ | grep -v "^[0-9]" | grep -v "^_archive" | grep -v "^README.md"
|
|
101
|
-
|
|
102
|
-
# Check for misplaced files in increment roots:
|
|
103
|
-
find .specweave/increments -maxdepth 2 -type f ! -name "spec.md" ! -name "plan.md" ! -name "tasks.md" ! -name "metadata.json" | grep -E "/[0-9]{4}-"
|
|
104
|
-
```
|
|
105
|
-
|
|
106
|
-
---
|
|
107
|
-
|
|
108
|
-
## 3. Protected Directories
|
|
109
|
-
|
|
110
|
-
**Never delete**: `.specweave/docs/`, `.specweave/increments/`
|
|
111
|
-
**Pre-commit hook blocks**: 50+ file deletions, `rm -rf` on protected dirs
|
|
112
|
-
**Recovery**: `git restore .specweave/`
|
|
113
|
-
|
|
114
|
-
---
|
|
115
|
-
|
|
116
|
-
## 4-6. Safety Rules
|
|
117
|
-
|
|
118
|
-
**4. Test Cleanup**: `pwd` check → dry-run → count → confirm → execute
|
|
119
|
-
**5. NEVER**: `specweave init . --force` (deletes all without backup)
|
|
120
|
-
**6. Completion**: `/specweave:done 0043` (validates), NEVER manual `metadata.json` edit
|
|
121
|
-
|
|
122
|
-
---
|
|
123
|
-
|
|
124
|
-
## 7. Source of Truth: tasks.md + spec.md (CRITICAL!)
|
|
22
|
+
### 2. Source of Truth
|
|
125
23
|
|
|
126
|
-
**
|
|
24
|
+
**tasks.md + spec.md are SOURCE OF TRUTH** (not internal TODO)
|
|
127
25
|
|
|
128
|
-
**MANDATORY workflow**:
|
|
129
26
|
```typescript
|
|
130
|
-
//
|
|
131
|
-
await work();
|
|
27
|
+
// After completing work - IMMEDIATELY update both:
|
|
132
28
|
TodoWrite([{task: "T-013", status: "completed"}]);
|
|
133
29
|
Edit("tasks.md", "**Status**: [ ] pending", "**Status**: [x] completed");
|
|
134
30
|
Edit("spec.md", "- [ ] **AC-US1-01**", "- [x] **AC-US1-01**");
|
|
135
31
|
```
|
|
136
32
|
|
|
137
|
-
|
|
138
|
-
**GitHub Duplicates**: Use `DuplicateDetector.createWithProtection()`, NEVER `--limit 1` in gh searches
|
|
139
|
-
**Validation**: `/specweave:validate-status`
|
|
33
|
+
### 3. Protected Directories
|
|
140
34
|
|
|
141
|
-
**
|
|
142
|
-
|
|
143
|
-
grep "^\*\*Status\*\*:" tasks.md | grep -c "\[x\] completed" # Must equal total
|
|
144
|
-
grep -c "^- \[x\] \*\*AC-" spec.md # Must equal total ACs
|
|
145
|
-
```
|
|
146
|
-
|
|
147
|
-
---
|
|
35
|
+
**NEVER delete**: `.specweave/docs/`, `.specweave/increments/`
|
|
36
|
+
**NEVER run**: `specweave init . --force` (deletes all without backup)
|
|
148
37
|
|
|
149
|
-
###
|
|
38
|
+
### 4. Skills Must NOT Spawn Large Agents
|
|
150
39
|
|
|
151
|
-
**
|
|
152
|
-
|
|
153
|
-
**Required Format**:
|
|
154
|
-
```markdown
|
|
155
|
-
## Acceptance Criteria
|
|
156
|
-
<!-- Auto-synced from living docs -->
|
|
157
|
-
### US-001: Title
|
|
158
|
-
- [ ] **AC-US1-01**: Description
|
|
159
|
-
```
|
|
160
|
-
|
|
161
|
-
**If missing**: `/specweave:embed-acs 0050` (auto-embeds from living docs)
|
|
162
|
-
**Validation**: `/specweave:do` blocks if ACs missing
|
|
163
|
-
|
|
164
|
-
---
|
|
165
|
-
|
|
166
|
-
### 7b. AC Sync Parser (v0.25.2)
|
|
167
|
-
|
|
168
|
-
**Both formats supported**: `- [x] Done` (legacy list) OR `**Status**: [x] completed` (field format)
|
|
169
|
-
|
|
170
|
-
---
|
|
171
|
-
|
|
172
|
-
## 8. Logger Abstraction
|
|
173
|
-
|
|
174
|
-
**Rule**: ALL `src/` code uses logger injection, NEVER `console.*`
|
|
40
|
+
**Skills spawning content-generating agents = CRASH** (context explosion)
|
|
175
41
|
|
|
176
42
|
```typescript
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
this.logger = options.logger ?? consoleLogger;
|
|
180
|
-
}
|
|
181
|
-
```
|
|
182
|
-
|
|
183
|
-
**Exception**: `src/cli/commands/*.ts` may use `console.*` with comment explaining it's user-facing output
|
|
184
|
-
|
|
185
|
-
---
|
|
186
|
-
|
|
187
|
-
### 8a. Native fs
|
|
188
|
-
|
|
189
|
-
**Use native Node.js `fs`, NEVER `fs-extra`**
|
|
43
|
+
// ❌ FORBIDDEN in skills:
|
|
44
|
+
Task({ subagent_type: "specweave:architect:architect" }); // 1000-3000 lines output
|
|
190
45
|
|
|
191
|
-
|
|
192
|
-
// ✅ CORRECT
|
|
193
|
-
import { existsSync, readFileSync } from 'fs';
|
|
194
|
-
import { promises as fs } from 'fs';
|
|
195
|
-
import { mkdirpSync, writeJsonSync } from '../utils/fs-native.js';
|
|
46
|
+
// ✅ CORRECT: Skills create templates, guide user to invoke agents in main context
|
|
196
47
|
```
|
|
197
48
|
|
|
198
49
|
---
|
|
199
50
|
|
|
200
|
-
##
|
|
51
|
+
## Development Setup
|
|
201
52
|
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
5. Functions < 100 lines
|
|
208
|
-
6. Custom error types
|
|
209
|
-
7. Comment "why" not "what"
|
|
210
|
-
8. No hardcoded secrets
|
|
211
|
-
9. No N+1 queries
|
|
212
|
-
10. Naming: camelCase (vars), PascalCase (classes), UPPER_SNAKE_CASE (constants)
|
|
53
|
+
```bash
|
|
54
|
+
npm install && npm run rebuild
|
|
55
|
+
npm run rebuild && npm test
|
|
56
|
+
git add . && git commit -m "feat: feature" && git push origin develop
|
|
57
|
+
```
|
|
213
58
|
|
|
214
|
-
**
|
|
59
|
+
**Marketplace**: `bash scripts/refresh-marketplace.sh` (GitHub mode, always use)
|
|
60
|
+
**NPM Release**: `/specweave-release:npm`
|
|
215
61
|
|
|
216
62
|
---
|
|
217
63
|
|
|
218
|
-
##
|
|
219
|
-
|
|
220
|
-
**ONLY Correct Format**: `[FS-XXX][US-YYY] User Story Title`
|
|
64
|
+
## Coding Standards
|
|
221
65
|
|
|
222
|
-
**
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
66
|
+
1. **Logger injection**: ALL `src/` code uses `logger`, NEVER `console.*`
|
|
67
|
+
```typescript
|
|
68
|
+
import { Logger, consoleLogger } from '../../utils/logger.js';
|
|
69
|
+
constructor(options: { logger?: Logger } = {}) {
|
|
70
|
+
this.logger = options.logger ?? consoleLogger;
|
|
71
|
+
}
|
|
72
|
+
```
|
|
73
|
+
2. **Imports**: ALWAYS `.js` extensions
|
|
74
|
+
3. **Tests**: `.test.ts` files, `vi.fn()` (not jest), `os.tmpdir()` (not cwd)
|
|
75
|
+
4. **Filesystem**: Native `fs` only (NEVER `fs-extra`)
|
|
76
|
+
5. **Code**: Functions < 100 lines, avoid `any`, custom error types
|
|
227
77
|
|
|
228
78
|
---
|
|
229
79
|
|
|
230
|
-
|
|
80
|
+
## Folder Structure
|
|
231
81
|
|
|
232
|
-
**
|
|
233
|
-
**ONLY ALLOWED**: `INCREMENT → FEATURE → USER STORIES` (forward reference only)
|
|
82
|
+
**At `.specweave/increments/` root - ONLY**: `####-name/` folders, `_archive/`, `README.md`
|
|
234
83
|
|
|
235
|
-
**
|
|
84
|
+
**Inside increment folders - ONLY at root**: `spec.md`, `plan.md`, `tasks.md`, `metadata.json`
|
|
85
|
+
**Everything else → subfolders**: `reports/`, `scripts/`, `logs/`, `backups/`, `docs/`
|
|
236
86
|
|
|
237
87
|
---
|
|
238
88
|
|
|
239
|
-
##
|
|
89
|
+
## Key Formats
|
|
240
90
|
|
|
91
|
+
### Task Format (MANDATORY)
|
|
241
92
|
```markdown
|
|
242
93
|
### T-001: Task Title
|
|
243
94
|
**User Story**: US-001 ← MANDATORY
|
|
@@ -245,383 +96,107 @@ import { mkdirpSync, writeJsonSync } from '../utils/fs-native.js';
|
|
|
245
96
|
**Status**: [x] completed
|
|
246
97
|
```
|
|
247
98
|
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
**Format**: `XXXX-decision-title.md` (4-digit, kebab-case, NO `adr-` prefix)
|
|
253
|
-
**Header**: `# ADR-XXXX: Decision Title`
|
|
254
|
-
**Location**: `.specweave/docs/internal/architecture/adr/`
|
|
255
|
-
|
|
256
|
-
**Auto-numbering**:
|
|
257
|
-
```bash
|
|
258
|
-
ls .specweave/docs/internal/architecture/adr/*.md | grep -E '/[0-9]{4}-' | \
|
|
259
|
-
sed 's/.*\/\([0-9][0-9][0-9][0-9]\)-.*/\1/' | sort -u | tail -1 | \
|
|
260
|
-
awk '{printf "Next ADR: %04d\n", $1 + 1}'
|
|
261
|
-
```
|
|
262
|
-
|
|
263
|
-
---
|
|
264
|
-
|
|
265
|
-
## 13. Structured Data Matching
|
|
99
|
+
### GitHub Issue Format
|
|
100
|
+
**ONLY**: `[FS-XXX][US-YYY] User Story Title`
|
|
101
|
+
**PROHIBITED**: `[SP-*]`, `[FS-XXX]` alone, `[undefined][US-XXX]`
|
|
266
102
|
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
```typescript
|
|
270
|
-
// ❌ WRONG: content.includes('FS-039') // Matches "See FS-039"!
|
|
271
|
-
// ✅ CORRECT: const match = content.match(/^feature_id:\s*["']?([^"'\n]+)["']?$/m);
|
|
272
|
-
```
|
|
273
|
-
|
|
274
|
-
---
|
|
275
|
-
|
|
276
|
-
## 14. Marketplace Plugin Completeness
|
|
277
|
-
|
|
278
|
-
**Complete plugin requires**: `agents/`, `commands/`, OR `lib/` (not just `.claude-plugin/` + `skills/`)
|
|
279
|
-
|
|
280
|
-
**MANDATORY**: `bash scripts/validate-marketplace-plugins.sh`
|
|
281
|
-
|
|
282
|
-
---
|
|
283
|
-
|
|
284
|
-
## 15. Skills vs Agents
|
|
285
|
-
|
|
286
|
-
| Aspect | Skills | Agents |
|
|
287
|
-
|--------|--------|--------|
|
|
288
|
-
| **Location** | `plugins/*/skills/name/SKILL.md` | `plugins/*/agents/name/AGENT.md` |
|
|
289
|
-
| **Invocation** | `Skill()` or `/command` | `Task()` with `subagent_type` |
|
|
290
|
-
| **Activation** | Automatic (keywords) | Explicit |
|
|
291
|
-
|
|
292
|
-
**Agent naming**: `{plugin}:{directory}:{yaml-name}`
|
|
293
|
-
|
|
294
|
-
### Skills Must NOT Spawn Large Content-Generating Agents (ADR-0133)
|
|
295
|
-
|
|
296
|
-
**CRITICAL**: Skills spawning agents via `Task()` causes Claude Code crashes due to context explosion.
|
|
297
|
-
|
|
298
|
-
**Problem**: Skill (1500 lines) + Agent (600 lines) + Agent output (2000+ lines) = 4000+ lines in memory = CRASH 💥
|
|
299
|
-
|
|
300
|
-
**❌ FORBIDDEN**:
|
|
301
|
-
```typescript
|
|
302
|
-
// In a skill SKILL.md:
|
|
303
|
-
Task({
|
|
304
|
-
subagent_type: "specweave:architect:architect", // ❌ Generates 1000-3000 lines
|
|
305
|
-
subagent_type: "specweave:pm:pm", // ❌ Generates 500-2000 lines
|
|
306
|
-
subagent_type: "specweave:test-aware-planner", // ❌ Generates 500-1500 lines
|
|
307
|
-
});
|
|
308
|
-
```
|
|
309
|
-
|
|
310
|
-
**✅ CORRECT**:
|
|
311
|
-
```typescript
|
|
312
|
-
// Skills create templates and guide users:
|
|
313
|
-
1. Create basic templates (< 50 lines each)
|
|
314
|
-
2. Output: "Tell Claude: 'Complete the spec for increment 0005-feature'"
|
|
315
|
-
3. Agents activate in MAIN context (not nested) = SAFE
|
|
316
|
-
```
|
|
317
|
-
|
|
318
|
-
**When to use Task() from skills**:
|
|
319
|
-
- ✅ Small utility agents (output < 200 lines)
|
|
320
|
-
- ✅ Data processing agents (no large generation)
|
|
321
|
-
- ❌ Content generators (specs, ADRs, plans, tasks)
|
|
322
|
-
|
|
323
|
-
**Main Context Pattern**: Same explosion occurs when editing files outside active increments. Large increment spec (800+ lines) + unrelated file edit (2000+ lines) + tool invocation (AskUserQuestion) = crash. Solution: Pause increment before editing unrelated files (see Section 0).
|
|
324
|
-
|
|
325
|
-
**Reference**: ADR-0133, Architect crash incident (2025-11-24, Increment 0052); Context explosion incident (2025-11-24, Increment 0058, init.ts edit)
|
|
326
|
-
|
|
327
|
-
---
|
|
328
|
-
|
|
329
|
-
## 16. YAML Frontmatter
|
|
330
|
-
|
|
331
|
-
**Required**:
|
|
103
|
+
### YAML Frontmatter (spec.md)
|
|
332
104
|
```yaml
|
|
333
105
|
---
|
|
334
|
-
increment: 0001-feature-name # REQUIRED
|
|
106
|
+
increment: 0001-feature-name # REQUIRED
|
|
335
107
|
feature_id: FS-001 # OPTIONAL
|
|
336
108
|
---
|
|
337
109
|
```
|
|
338
110
|
|
|
339
|
-
|
|
111
|
+
### ADR Naming
|
|
112
|
+
**Format**: `XXXX-decision-title.md` (4-digit, NO `adr-` prefix)
|
|
113
|
+
**Location**: `.specweave/docs/internal/architecture/adr/`
|
|
340
114
|
|
|
341
115
|
---
|
|
342
116
|
|
|
343
|
-
##
|
|
117
|
+
## Important Rules
|
|
344
118
|
|
|
345
|
-
|
|
346
|
-
|
|
119
|
+
### NO Increment-to-Increment References
|
|
120
|
+
**FORBIDDEN**: User stories referencing increments (`increments: [0050-...]`)
|
|
121
|
+
**ONLY ALLOWED**: `INCREMENT → FEATURE → USER STORIES` (forward reference only)
|
|
347
122
|
|
|
348
|
-
|
|
123
|
+
### Structured Data Matching
|
|
349
124
|
```typescript
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
const result = await provider.validateRepository('owner', 'repo', token);
|
|
125
|
+
// ❌ WRONG: content.includes('FS-039') // Matches "See FS-039"!
|
|
126
|
+
// ✅ CORRECT: content.match(/^feature_id:\s*["']?([^"'\n]+)["']?$/m)
|
|
353
127
|
```
|
|
354
128
|
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
---
|
|
358
|
-
|
|
359
|
-
### 17a. GitHub Multi-Repo Init Flow (v0.26.3 - ADR-0132)
|
|
129
|
+
### GitHub Duplicates
|
|
130
|
+
Use `DuplicateDetector.createWithProtection()`, NEVER `--limit 1` in gh searches
|
|
360
131
|
|
|
361
|
-
|
|
132
|
+
### AC Presence in spec.md
|
|
133
|
+
**MANDATORY** - even with external living docs. Use `/specweave:embed-acs` if missing.
|
|
362
134
|
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
// ✅ let mapped = undefined; if (option === 'advanced') mapped = 'enhanced';
|
|
366
|
-
```
|
|
135
|
+
### Git Provider Abstraction
|
|
136
|
+
Use `getPlatformRegistry().getProvider('github')`. NEVER hardcode platform names/endpoints.
|
|
367
137
|
|
|
368
138
|
---
|
|
369
139
|
|
|
370
|
-
##
|
|
371
|
-
|
|
372
|
-
### **How GitHub Issue Sync Works**
|
|
373
|
-
|
|
374
|
-
**3-Phase Sync Flow**:
|
|
375
|
-
```
|
|
376
|
-
TodoWrite → Hook → US Completion Orchestrator → Living Docs Sync → External Tool Sync → GitHub Issues Updated
|
|
377
|
-
```
|
|
378
|
-
|
|
379
|
-
**Phase 1: Task Completion Detection**
|
|
380
|
-
- User marks task complete via `TodoWrite`
|
|
381
|
-
- `post-task-completion.sh` fires (sets `SKIP_GITHUB_SYNC=true` to prevent duplicate syncs)
|
|
382
|
-
- `consolidated-sync.js` runs 6 operations sequentially
|
|
383
|
-
|
|
384
|
-
**Phase 2: US Completion Orchestration**
|
|
385
|
-
- `syncCompletedUserStories()` (operation 5 of 6) detects newly completed user stories
|
|
386
|
-
- Checks if all ACs for a US are complete (100% → status: "completed")
|
|
387
|
-
- **Throttle**: 60s window prevents spam (manual override: `/specweave:sync-progress`)
|
|
388
|
-
- If newly completed USs found → triggers Phase 3
|
|
389
|
-
|
|
390
|
-
**Phase 3: External Tool Sync**
|
|
391
|
-
- `LivingDocsSync.syncIncrement()` called
|
|
392
|
-
- `detectExternalTools()` checks **3 levels** for GitHub config:
|
|
393
|
-
- **Level 1**: `metadata.json` (increment-cached links)
|
|
394
|
-
- **Level 2**: `config.json` - **4 detection methods** (ADR-0137):
|
|
395
|
-
- Method 1: `config.sync.github.enabled` ← **Most common (60% of users)**
|
|
396
|
-
- Method 2: `config.sync.profiles[activeProfile]` ← Multi-profile setups
|
|
397
|
-
- Method 3: `config.multiProject.projects[project].externalTools.github` ← Multi-project
|
|
398
|
-
- Method 4: `config.plugins.settings['specweave-github']` ← Legacy
|
|
399
|
-
- **Level 3**: Environment variables (`GITHUB_TOKEN` + `GITHUB_OWNER`/`GITHUB_REPOSITORY`)
|
|
400
|
-
- If GitHub detected → `syncToGitHub()` → `GitHubFeatureSync.syncFeatureToGitHub()`
|
|
401
|
-
- Updates GitHub issues with completed AC checkboxes
|
|
402
|
-
|
|
403
|
-
### **GitHub Configuration (Required)**
|
|
404
|
-
|
|
405
|
-
**Recommended Setup (Pattern 1 - Simplest)**:
|
|
406
|
-
```json
|
|
407
|
-
// .specweave/config.json
|
|
408
|
-
{
|
|
409
|
-
"sync": {
|
|
410
|
-
"github": {
|
|
411
|
-
"enabled": true,
|
|
412
|
-
"owner": "your-org",
|
|
413
|
-
"repo": "your-repo"
|
|
414
|
-
}
|
|
415
|
-
}
|
|
416
|
-
}
|
|
417
|
-
```
|
|
418
|
-
|
|
419
|
-
**Plus `.env`**:
|
|
420
|
-
```bash
|
|
421
|
-
GITHUB_TOKEN=ghp_your_token_here
|
|
422
|
-
GITHUB_OWNER=your-org # Optional if in config.json
|
|
423
|
-
GITHUB_REPO=your-repo # Optional if in config.json
|
|
424
|
-
```
|
|
425
|
-
|
|
426
|
-
**Diagnostic**: Run `node dist/test-github-detection.js` to verify detection (create this file if needed)
|
|
140
|
+
## Configuration
|
|
427
141
|
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
**Issue**: GitHub issues not updating after US completion
|
|
431
|
-
**Diagnosis**:
|
|
432
|
-
```bash
|
|
433
|
-
# 1. Check detection
|
|
434
|
-
grep "External tools detected" .specweave/logs/hooks-debug.log | tail -5
|
|
435
|
-
# Should see: "📡 External tools detected: github"
|
|
436
|
-
|
|
437
|
-
# 2. Check config
|
|
438
|
-
cat .specweave/config.json | jq '.sync.github'
|
|
439
|
-
# Should have: enabled: true, owner: "...", repo: "..."
|
|
440
|
-
|
|
441
|
-
# 3. Check throttle
|
|
442
|
-
grep "throttled" .specweave/logs/hooks-debug.log | tail -3
|
|
443
|
-
# If throttled → wait 60s OR run: /specweave:sync-progress
|
|
444
|
-
```
|
|
445
|
-
|
|
446
|
-
**Issue**: Throttle blocking sync
|
|
447
|
-
**Solution**: Manual sync (bypasses throttle):
|
|
448
|
-
```bash
|
|
449
|
-
/specweave:sync-progress 0054 # Sync specific increment
|
|
450
|
-
/specweave-github:sync FS-054 # Sync entire feature
|
|
451
|
-
```
|
|
452
|
-
|
|
453
|
-
**Issue**: Detection not finding GitHub config
|
|
454
|
-
**Fix**: ADR-0137 enhanced detection (v0.26.3+)
|
|
455
|
-
- Checks 4 config locations + env vars
|
|
456
|
-
- Update to latest version: `npm update specweave`
|
|
457
|
-
|
|
458
|
-
## Hook Performance & Safety
|
|
459
|
-
|
|
460
|
-
**Emergency**: `export SPECWEAVE_DISABLE_HOOKS=1` → `rm -f .specweave/state/.hook-*` → `npm run rebuild`
|
|
461
|
-
|
|
462
|
-
**Mandatory Checklist**: PROJECT_ROOT first, kill switch, circuit breaker, file lock, debounce (5s), `set +e`, `exit 0`, active-only filtering
|
|
463
|
-
**Never**: `set -e`, sync spawns, error propagation
|
|
464
|
-
**Targets**: <100ms, 0-2 processes, 0 breaker trips
|
|
465
|
-
|
|
466
|
-
**Critical Fixes**:
|
|
467
|
-
- v0.26.3: **Multi-location GitHub config detection!** (ADR-0137) → Checks 4 config patterns + env vars
|
|
468
|
-
- v0.26.1: **Automatic US sync restored!** `SKIP_US_SYNC` removed → Smart throttle (60s window) → fs.writeFile() validated safe
|
|
469
|
-
- v0.25.2: `SKIP_EXTERNAL_SYNC` guard at LivingDocsSync layer → prevents recursion cascade
|
|
470
|
-
- v0.25.1: TodoWrite crash → emergency `SKIP_US_SYNC=true` → manual `/specweave:sync-progress` (temporary fix)
|
|
471
|
-
- v0.25.0: 6→4 hooks (33% reduction)
|
|
472
|
-
- v0.24.4: State-based filtering (95% overhead reduction)
|
|
473
|
-
- v0.26.1: PROJECT_ROOT before RECURSION_GUARD_FILE (order bug fix)
|
|
142
|
+
**Secrets** (`.env`, gitignored): Tokens, PATs, emails
|
|
143
|
+
**Config** (`.specweave/config.json`, committed): Domains, strategies, sync settings
|
|
474
144
|
|
|
475
145
|
---
|
|
476
146
|
|
|
477
|
-
##
|
|
147
|
+
## Commands
|
|
478
148
|
|
|
479
|
-
**Core commands**:
|
|
480
149
|
```bash
|
|
481
|
-
/specweave:increment "feature" # Plan
|
|
482
|
-
/specweave:do # Execute
|
|
483
|
-
/specweave:
|
|
484
|
-
/specweave:
|
|
485
|
-
/specweave:
|
|
486
|
-
/specweave:validate 0001 # Validate
|
|
487
|
-
/specweave:qa 0001 # Quality check
|
|
488
|
-
|
|
489
|
-
# Feature deletion
|
|
490
|
-
specweave delete-feature FS-042 --dry-run # Preview
|
|
491
|
-
specweave delete-feature FS-042 # Safe delete (requires confirmation)
|
|
492
|
-
specweave delete-feature FS-042 --force # Force (orphans active increments)
|
|
150
|
+
/specweave:increment "feature" # Plan new increment
|
|
151
|
+
/specweave:do # Execute tasks
|
|
152
|
+
/specweave:done 0002 # Close (validates gates)
|
|
153
|
+
/specweave:progress # Show status
|
|
154
|
+
/specweave:sync-progress # Full sync (tasks→docs→GitHub/JIRA/ADO)
|
|
155
|
+
/specweave:validate 0001 # Validate increment
|
|
493
156
|
```
|
|
494
157
|
|
|
495
158
|
---
|
|
496
159
|
|
|
497
160
|
## Build & Test
|
|
498
161
|
|
|
499
|
-
**Build**: `npm run rebuild` (clean + build), `npm run build`
|
|
500
|
-
**Architecture**: `tsc` → `dist/src/`, esbuild → hooks, copy deps → `plugins/*/lib/vendor/`
|
|
501
|
-
**CRITICAL**: Always `.js` extensions in imports
|
|
502
|
-
|
|
503
|
-
**Test**:
|
|
504
162
|
```bash
|
|
505
|
-
npm
|
|
506
|
-
npm
|
|
507
|
-
npm run test:
|
|
508
|
-
npm run test:all # All
|
|
509
|
-
npm run test:coverage # Coverage (80%+ required)
|
|
163
|
+
npm run rebuild # Clean + build (tsc → dist/, esbuild → hooks)
|
|
164
|
+
npm test # Smoke tests
|
|
165
|
+
npm run test:all # All tests (80%+ coverage required)
|
|
510
166
|
```
|
|
511
167
|
|
|
512
|
-
**
|
|
513
|
-
|
|
514
|
-
---
|
|
515
|
-
|
|
516
|
-
## Configuration Management
|
|
517
|
-
|
|
518
|
-
**Secrets** (.env, gitignored) vs **Config** (.specweave/config.json, committed)
|
|
519
|
-
|
|
520
|
-
| Type | Location | Committed? |
|
|
521
|
-
|------|----------|------------|
|
|
522
|
-
| Tokens/Emails | `.env` | ❌ |
|
|
523
|
-
| Domains/Strategies | `config.json` | ✅ |
|
|
524
|
-
|
|
525
|
-
---
|
|
526
|
-
|
|
527
|
-
## Cache Management
|
|
528
|
-
|
|
529
|
-
**Location**: `.specweave/cache/`, **TTL**: 24 hours
|
|
530
|
-
|
|
531
|
-
**Cached**: JIRA projects, ADO config, boards, components (NOT tokens/PATs)
|
|
532
|
-
|
|
533
|
-
**Manual**: `/specweave-jira:refresh-cache --all`, `/specweave:cleanup-cache --older-than 7d`
|
|
534
|
-
|
|
535
|
-
---
|
|
536
|
-
|
|
537
|
-
## Comprehensive Progress Sync
|
|
538
|
-
|
|
539
|
-
**Command**: `/specweave:sync-progress [increment]`
|
|
540
|
-
|
|
541
|
-
**Flow**: tasks.md → spec.md ACs → living docs → external tools (GitHub/JIRA/ADO) → status line
|
|
542
|
-
|
|
543
|
-
**Replaces 4 commands**: `/specweave:sync-acs` + `/specweave:sync-specs` + `/specweave-github:sync` + `/specweave:update-status`
|
|
544
|
-
|
|
545
|
-
**Flags**: `--dry-run`, `--no-github`, `--no-jira`, `--no-ado`, `--force`
|
|
546
|
-
|
|
547
|
-
**When to use**: After completing tasks, before closing increment, bulk completion
|
|
548
|
-
|
|
549
|
-
---
|
|
550
|
-
|
|
551
|
-
## Safe Feature Deletion
|
|
552
|
-
|
|
553
|
-
**Command**: `specweave delete-feature <feature-id>`
|
|
554
|
-
|
|
555
|
-
**4-Tier Validation**: Feature detection → active increment check → git status → GitHub scan
|
|
556
|
-
**3-Phase Commit**: Validation → staging (reversible) → commit (irreversible)
|
|
557
|
-
**Multi-Gate Confirmation**: Primary (y/N) → elevated (type "delete" in force mode) → GitHub (separate)
|
|
558
|
-
|
|
559
|
-
**Deletes**: Living docs FEATURE.md, user stories, README, GitHub issues
|
|
560
|
-
**NOT deleted**: Increments (metadata.json updated if orphaned)
|
|
561
|
-
|
|
562
|
-
**Modes**: Safe (default, blocks active increments), Force (`--force`, orphans increments), Dry-run (`--dry-run`, preview)
|
|
563
|
-
|
|
564
|
-
**Audit**: `.specweave/logs/feature-deletions.log` (JSON Lines, includes commit SHA)
|
|
168
|
+
**Plugin validation**: `bash scripts/validate-marketplace-plugins.sh`
|
|
565
169
|
|
|
566
170
|
---
|
|
567
171
|
|
|
568
|
-
##
|
|
172
|
+
## Emergency
|
|
569
173
|
|
|
174
|
+
```bash
|
|
175
|
+
export SPECWEAVE_DISABLE_HOOKS=1
|
|
176
|
+
rm -f .specweave/state/.hook-*
|
|
177
|
+
npm run rebuild
|
|
570
178
|
```
|
|
571
|
-
src/ # TypeScript → dist/
|
|
572
|
-
plugins/ # Skills, agents, commands, hooks
|
|
573
|
-
├── specweave/ # Core
|
|
574
|
-
└── specweave-*/ # Optional
|
|
575
|
-
.specweave/ # Increments, docs, logs
|
|
576
|
-
```
|
|
577
|
-
|
|
578
|
-
---
|
|
579
179
|
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
**Valid events** (10): PostToolUse, PreToolUse, PermissionRequest, Notification, UserPromptSubmit, Stop, SubagentStop, PreCompact, SessionStart, SessionEnd
|
|
583
|
-
|
|
584
|
-
```json
|
|
585
|
-
{
|
|
586
|
-
"hooks": {
|
|
587
|
-
"PostToolUse": [{
|
|
588
|
-
"matcher": "TodoWrite",
|
|
589
|
-
"hooks": [{ "type": "command", "command": "${CLAUDE_PLUGIN_ROOT}/hooks/post-task-completion.sh", "timeout": 10 }]
|
|
590
|
-
}]
|
|
591
|
-
}
|
|
592
|
-
}
|
|
593
|
-
```
|
|
180
|
+
**Recovery docs**: `.specweave/docs/internal/emergency-procedures/`
|
|
594
181
|
|
|
595
182
|
---
|
|
596
183
|
|
|
597
184
|
## Quick Reference
|
|
598
185
|
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
**Remember**:
|
|
606
|
-
1. Push → GitHub → auto-updates (5-10s)
|
|
607
|
-
2. **Keep increment roots clean**: Only spec.md, plan.md, tasks.md, metadata.json. Everything else in subfolders (reports/, scripts/, logs/, backups/, docs/)
|
|
608
|
-
3. Test before commit
|
|
609
|
-
4. NEVER delete `.specweave/`
|
|
610
|
-
5. Use `/specweave:done` (not manual edits)
|
|
611
|
-
6. ALWAYS use GitHub mode for marketplace refresh (unless actively developing uncommitted changes)
|
|
612
|
-
7. tasks.md + spec.md are SOURCE OF TRUTH (not internal TODO)
|
|
613
|
-
8. Pause large increments (10+ tasks) before editing unrelated files to prevent crashes
|
|
614
|
-
|
|
615
|
-
**See**: `.github/CONTRIBUTING.md`, https://spec-weave.com
|
|
186
|
+
| Aspect | Rule |
|
|
187
|
+
|--------|------|
|
|
188
|
+
| Skills vs Agents | Skills = auto-activate (keywords), Agents = explicit `Task()` |
|
|
189
|
+
| Hook events | PostToolUse, PreToolUse, UserPromptSubmit, Stop, SessionStart/End, etc. |
|
|
190
|
+
| Cache location | `.specweave/cache/` (24h TTL) |
|
|
191
|
+
| Pre-commit | Blocks 50+ deletions, `rm -rf` on protected dirs |
|
|
616
192
|
|
|
617
193
|
---
|
|
618
194
|
|
|
619
195
|
## References
|
|
620
196
|
|
|
621
|
-
**
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
**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), 0058 (Context explosion, init.ts edit crash)
|
|
197
|
+
**Internal Docs**: `.specweave/docs/internal/`
|
|
198
|
+
- `sync-architecture.md` - GitHub sync flow, troubleshooting
|
|
199
|
+
- `architecture/adr/` - Decision records (ADR-0032, 0060, 0129, etc.)
|
|
200
|
+
- `emergency-procedures/` - Crash recovery guides
|
|
626
201
|
|
|
627
|
-
**
|
|
202
|
+
**External**: `.github/CONTRIBUTING.md`, https://spec-weave.com
|