specweave 0.22.3 → 0.22.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 +281 -1050
- package/dist/src/cli/commands/init.d.ts +2 -0
- package/dist/src/cli/commands/init.d.ts.map +1 -1
- package/dist/src/cli/commands/init.js +141 -95
- package/dist/src/cli/commands/init.js.map +1 -1
- package/dist/src/cli/commands/sync-specs.d.ts +4 -1
- package/dist/src/cli/commands/sync-specs.d.ts.map +1 -1
- package/dist/src/cli/commands/sync-specs.js +99 -49
- package/dist/src/cli/commands/sync-specs.js.map +1 -1
- package/dist/src/core/cicd/workflow-monitor.d.ts +4 -0
- package/dist/src/core/cicd/workflow-monitor.d.ts.map +1 -1
- package/dist/src/core/cicd/workflow-monitor.js +6 -2
- package/dist/src/core/cicd/workflow-monitor.js.map +1 -1
- package/dist/src/core/increment/increment-archiver.d.ts +4 -1
- package/dist/src/core/increment/increment-archiver.d.ts.map +1 -1
- package/dist/src/core/increment/increment-archiver.js +21 -9
- package/dist/src/core/increment/increment-archiver.js.map +1 -1
- package/dist/src/core/increment/metadata-manager.d.ts +22 -0
- package/dist/src/core/increment/metadata-manager.d.ts.map +1 -1
- package/dist/src/core/increment/metadata-manager.js +57 -5
- package/dist/src/core/increment/metadata-manager.js.map +1 -1
- package/dist/src/core/increment/spec-sync-manager.d.ts +5 -1
- package/dist/src/core/increment/spec-sync-manager.d.ts.map +1 -1
- package/dist/src/core/increment/spec-sync-manager.js +4 -2
- package/dist/src/core/increment/spec-sync-manager.js.map +1 -1
- package/dist/src/core/increment-utils.d.ts.map +1 -1
- package/dist/src/core/increment-utils.js +18 -1
- package/dist/src/core/increment-utils.js.map +1 -1
- package/dist/src/core/living-docs/living-docs-sync.d.ts +5 -1
- package/dist/src/core/living-docs/living-docs-sync.d.ts.map +1 -1
- package/dist/src/core/living-docs/living-docs-sync.js +34 -32
- package/dist/src/core/living-docs/living-docs-sync.js.map +1 -1
- package/dist/src/core/living-docs/task-project-specific-generator.d.ts.map +1 -1
- package/dist/src/core/living-docs/task-project-specific-generator.js +13 -8
- package/dist/src/core/living-docs/task-project-specific-generator.js.map +1 -1
- package/dist/src/core/status-line/status-line-manager.d.ts.map +1 -1
- package/dist/src/core/status-line/status-line-manager.js +3 -1
- package/dist/src/core/status-line/status-line-manager.js.map +1 -1
- package/dist/src/integrations/jira/jira-incremental-mapper.d.ts.map +1 -1
- package/dist/src/integrations/jira/jira-incremental-mapper.js +4 -0
- package/dist/src/integrations/jira/jira-incremental-mapper.js.map +1 -1
- package/dist/src/integrations/jira/jira-mapper.d.ts.map +1 -1
- package/dist/src/integrations/jira/jira-mapper.js +4 -0
- package/dist/src/integrations/jira/jira-mapper.js.map +1 -1
- package/dist/src/utils/logger.d.ts +48 -0
- package/dist/src/utils/logger.d.ts.map +1 -0
- package/dist/src/utils/logger.js +53 -0
- package/dist/src/utils/logger.js.map +1 -0
- package/package.json +3 -2
- package/plugins/specweave/agents/code-standards-detective/AGENT.md +828 -0
- package/plugins/specweave/agents/test-aware-planner/templates/task-non-testable.md.template +12 -0
- package/plugins/specweave/agents/test-aware-planner/templates/task-testable.md.template +12 -0
- package/plugins/specweave/commands/specweave-analyze-standards.sh +315 -0
- package/plugins/specweave/commands/specweave-done.md +33 -2
- package/plugins/specweave/commands/specweave-sync-docs.md +66 -18
- package/plugins/specweave/hooks/lib/update-status-line.sh +5 -2
- package/plugins/specweave/skills/brownfield-analyzer/SKILL.md +40 -3
- package/plugins/specweave/skills/code-standards-analyzer/SKILL.md +455 -0
- package/plugins/specweave/templates/coding-standards.md.template +447 -0
- package/plugins/specweave-ado/lib/ado-multi-project-sync.js +1 -0
- package/plugins/specweave-ado/lib/enhanced-ado-sync.js +170 -0
- package/plugins/specweave-jira/lib/enhanced-jira-sync.js +3 -3
- package/plugins/specweave-release/hooks/.specweave/logs/dora-tracking.log +5238 -0
package/CLAUDE.md
CHANGED
|
@@ -1,1266 +1,497 @@
|
|
|
1
1
|
# SpecWeave - Development Guide
|
|
2
2
|
|
|
3
3
|
**Project**: SpecWeave - Spec-Driven Development Framework
|
|
4
|
-
**Type**:
|
|
4
|
+
**Type**: TypeScript CLI (NPM Package)
|
|
5
5
|
**Repository**: https://github.com/anton-abyzov/specweave
|
|
6
|
-
**Website**: https://spec-weave.com
|
|
7
6
|
|
|
8
|
-
|
|
9
|
-
Users receive a different CLAUDE.md via the template system.
|
|
7
|
+
For **contributors to SpecWeave itself** (not users).
|
|
10
8
|
|
|
11
9
|
---
|
|
12
10
|
|
|
13
|
-
##
|
|
11
|
+
## 🚨 CRITICAL SAFETY RULES
|
|
14
12
|
|
|
15
|
-
|
|
13
|
+
### 1. Symlink Setup (MANDATORY for Contributors)
|
|
16
14
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
Claude Code's hook execution system expects plugins at `~/.claude/plugins/marketplaces/specweave/`, but this path can be **either a directory OR a symlink**. The difference is critical:
|
|
20
|
-
|
|
21
|
-
| Type | Symbol | Behavior | Development Impact |
|
|
22
|
-
|------|--------|----------|-------------------|
|
|
23
|
-
| **Directory** | `drwxr-xr-x` | Stale copy from marketplace update | ❌ Hooks fail with "No such file or directory" |
|
|
24
|
-
| **Symlink** | `lrwxr-xr-x` | Live reference to repository | ✅ Hooks work, changes immediately reflected |
|
|
25
|
-
|
|
26
|
-
### Why This Matters
|
|
27
|
-
|
|
28
|
-
**Hooks ONLY work reliably with a symlink setup.** If the marketplace path is a directory:
|
|
29
|
-
- ❌ Post-task-completion hooks fail randomly
|
|
30
|
-
- ❌ Status line doesn't update
|
|
31
|
-
- ❌ Living docs don't sync
|
|
32
|
-
- ❌ You waste hours debugging "No such file or directory" errors
|
|
33
|
-
- ❌ Changes to hooks in your repo are NOT reflected until marketplace update
|
|
34
|
-
|
|
35
|
-
### How the Problem Occurs
|
|
36
|
-
|
|
37
|
-
1. **Initial setup**: You create a symlink (correct)
|
|
38
|
-
2. **Marketplace update**: Running `claude plugin marketplace update specweave` MAY replace the symlink with a directory copy
|
|
39
|
-
3. **Silent failure**: Hooks start failing but no clear error message points to symlink issue
|
|
40
|
-
|
|
41
|
-
### The Fix
|
|
15
|
+
**Problem**: Claude Code executes hooks from `~/.claude/plugins/marketplaces/specweave/`. If this is a **directory** (not symlink), hooks fail with "No such file or directory".
|
|
42
16
|
|
|
17
|
+
**Fix**:
|
|
43
18
|
```bash
|
|
44
|
-
#
|
|
19
|
+
# Verify symlink exists:
|
|
45
20
|
ls -ld ~/.claude/plugins/marketplaces/specweave
|
|
46
|
-
#
|
|
47
|
-
# NOT: drwxr-xr-x ... (DIRECTORY)
|
|
21
|
+
# Must show: lrwxr-xr-x ... -> /path/to/repo (SYMLINK, not drwxr-xr-x)
|
|
48
22
|
|
|
49
|
-
# If
|
|
23
|
+
# If directory, fix it:
|
|
50
24
|
rm -rf ~/.claude/plugins/marketplaces/specweave
|
|
51
25
|
ln -s "$(pwd)" ~/.claude/plugins/marketplaces/specweave
|
|
52
26
|
|
|
53
|
-
# Verify
|
|
27
|
+
# Verify:
|
|
54
28
|
bash .specweave/increments/0043-spec-md-desync-fix/scripts/verify-dev-setup.sh
|
|
55
29
|
```
|
|
56
30
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
1. ✅ **Pre-commit hook** verifies symlink before each commit (warns if broken)
|
|
60
|
-
2. ✅ **Verification script** checks all aspects of setup (see "Local Development Setup" below)
|
|
61
|
-
3. ✅ **This warning** ensures new contributors know about this issue
|
|
31
|
+
**Without symlink**: Hooks fail, status line broken, living docs don't sync.
|
|
32
|
+
**Protection**: Pre-commit hook verifies symlink before each commit.
|
|
62
33
|
|
|
63
|
-
###
|
|
34
|
+
### 2. NEVER Pollute Increment Folders
|
|
64
35
|
|
|
65
|
-
|
|
66
|
-
-
|
|
67
|
-
- **Fixes Applied**: `.specweave/increments/0043-spec-md-desync-fix/reports/HOOK-EXECUTION-ERRORS-FIXES-APPLIED-2025-11-18.md`
|
|
36
|
+
**ONLY 4 files allowed in `.specweave/increments/####/` root**:
|
|
37
|
+
- `spec.md`, `plan.md`, `tasks.md`, `metadata.json`
|
|
68
38
|
|
|
69
|
-
**
|
|
39
|
+
**Everything else → subfolders**:
|
|
40
|
+
- `reports/` - Analysis, completion reports, validation
|
|
41
|
+
- `scripts/` - Helper scripts, automation
|
|
42
|
+
- `logs/` - Execution logs, debug output
|
|
70
43
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
**⛔ THIS IS THE #1 RULE - VIOLATING THIS WILL GET YOUR PR REJECTED ⛔**
|
|
76
|
-
|
|
77
|
-
**ALL AI-generated files MUST go into the CURRENT INCREMENT folder**, NOT in the project root!
|
|
44
|
+
**Examples**:
|
|
45
|
+
```bash
|
|
46
|
+
# ❌ WRONG
|
|
47
|
+
.specweave/increments/0046/analysis-report.md
|
|
78
48
|
|
|
79
|
-
|
|
49
|
+
# ✅ CORRECT
|
|
50
|
+
.specweave/increments/0046/reports/analysis-report.md
|
|
80
51
|
|
|
52
|
+
# Fix before committing:
|
|
53
|
+
mkdir -p .specweave/increments/0046/reports
|
|
54
|
+
mv .specweave/increments/0046/*.md .specweave/increments/0046/reports/
|
|
55
|
+
git restore .specweave/increments/0046/{spec,plan,tasks}.md
|
|
81
56
|
```
|
|
82
|
-
❌ WRONG - ROOT FILES (REJECTED!):
|
|
83
|
-
/PLUGIN-MIGRATION-COMPLETE.md # NO! Goes to increment reports/
|
|
84
|
-
/SESSION-SUMMARY-2025-10-28.md # NO! Goes to increment reports/
|
|
85
|
-
/ADR-006-DEEP-ANALYSIS.md # NO! Goes to .specweave/docs/internal/architecture/adr/
|
|
86
|
-
/ANALYSIS-MULTI-TOOL-COMPARISON.md # NO! Goes to increment reports/
|
|
87
|
-
/QUICK-START.md # NO! Goes to increment reports/
|
|
88
|
-
/migration-helper.sh # NO! Goes to increment scripts/
|
|
89
|
-
/execution.log # NO! Goes to increment logs/
|
|
90
|
-
|
|
91
|
-
✅ CORRECT - INCREMENT FOLDERS:
|
|
92
|
-
.specweave/increments/0004-plugin-architecture/
|
|
93
|
-
├── spec.md # ⚠️ ONLY THESE 3 FILES in root!
|
|
94
|
-
├── plan.md
|
|
95
|
-
├── tasks.md # Tasks with embedded tests
|
|
96
|
-
├── reports/ # ✅ ALL REPORTS HERE!
|
|
97
|
-
│ ├── PLUGIN-MIGRATION-COMPLETE.md # ✅ Completion reports
|
|
98
|
-
│ ├── SESSION-SUMMARY.md # ✅ Session summaries
|
|
99
|
-
│ ├── QUICK-START.md # ✅ Quick start guides
|
|
100
|
-
│ └── ANALYSIS-*.md # ✅ Analysis files
|
|
101
|
-
├── scripts/ # ✅ ALL SCRIPTS HERE!
|
|
102
|
-
│ └── migration-helper.sh # ✅ Helper scripts
|
|
103
|
-
└── logs/ # ✅ ALL LOGS HERE!
|
|
104
|
-
└── execution.log # ✅ Execution logs
|
|
105
|
-
|
|
106
|
-
.specweave/docs/internal/architecture/ # ✅ PUT ADRS/DIAGRAMS HERE!
|
|
107
|
-
└── adr/
|
|
108
|
-
└── 0006-deep-analysis.md # ✅ Architecture decisions
|
|
109
|
-
```
|
|
110
|
-
|
|
111
|
-
**Before committing, ALWAYS check**: `git status` - If you see `.md` files in root, MOVE THEM!
|
|
112
|
-
|
|
113
|
-
### 📁 Increment Structure Rules (MANDATORY)
|
|
114
57
|
|
|
115
|
-
|
|
116
|
-
1. ✅ `spec.md` - Specification
|
|
117
|
-
2. ✅ `plan.md` - Implementation plan
|
|
118
|
-
3. ✅ `tasks.md` - Tasks with embedded tests
|
|
58
|
+
### 3. NEVER Delete .specweave/ Directories
|
|
119
59
|
|
|
120
|
-
**
|
|
121
|
-
- `reports/` - Session summaries, completion reports, analysis files, quick-start guides
|
|
122
|
-
- `scripts/` - Helper scripts, migrations, utilities
|
|
123
|
-
- `logs/` - Execution logs, debug output, temp files
|
|
60
|
+
**Protected**: `.specweave/docs/`, `.specweave/increments/`
|
|
124
61
|
|
|
125
|
-
**
|
|
126
|
-
- `
|
|
127
|
-
-
|
|
128
|
-
- `ULTRATHINK-*.md` → `reports/ULTRATHINK-*.md`
|
|
129
|
-
- `validation.sh` → `scripts/validation.sh`
|
|
130
|
-
- `debug.log` → `logs/debug.log`
|
|
62
|
+
**Pre-commit hook blocks**:
|
|
63
|
+
- `rm -rf .specweave/docs` or `rm -rf .specweave/increments`
|
|
64
|
+
- Deletion of 50+ files at once in these directories
|
|
131
65
|
|
|
132
|
-
**
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
- ✅ Consistent across all increments
|
|
66
|
+
**If accidental deletion**:
|
|
67
|
+
```bash
|
|
68
|
+
git restore .specweave/
|
|
69
|
+
```
|
|
137
70
|
|
|
138
|
-
|
|
71
|
+
### 4. Test Cleanup Safety (MANDATORY)
|
|
139
72
|
|
|
140
|
-
|
|
73
|
+
**Danger**: `rm -rf` with wrong `pwd` = delete entire test suite.
|
|
141
74
|
|
|
142
|
-
|
|
75
|
+
**REQUIRED steps before any `rm -rf`**:
|
|
76
|
+
1. Verify `pwd` (MUST be project root)
|
|
77
|
+
2. Dry-run with `-print` (NO deletion)
|
|
78
|
+
3. Count files/directories to delete
|
|
79
|
+
4. Manual confirmation (type "DELETE")
|
|
80
|
+
5. Execute deletion
|
|
81
|
+
6. Verify results
|
|
82
|
+
7. Run tests
|
|
143
83
|
|
|
144
|
-
**
|
|
145
|
-
- `.specweave/docs/` - All project documentation (internal + public)
|
|
146
|
-
- `.specweave/increments/` - All increment history and specifications
|
|
84
|
+
**Never** use `rm -rf` without ALL safety checks above.
|
|
147
85
|
|
|
148
|
-
|
|
149
|
-
- ❌ **NEVER** run `rm -rf .specweave/docs` or `rm -rf .specweave/increments`
|
|
150
|
-
- ❌ **NEVER** delete more than 50 files in these directories at once
|
|
151
|
-
- ✅ Pre-commit hook will **BLOCK** accidental mass deletions
|
|
152
|
-
- ✅ If intentional, bypass with `git commit --no-verify`
|
|
86
|
+
### 5. NEVER Use `specweave init . --force`
|
|
153
87
|
|
|
154
|
-
**
|
|
155
|
-
On 2025-11-17, an accidental mass deletion occurred (1,200+ files). All files were recovered via `git restore`, but this protection prevents future incidents.
|
|
88
|
+
**Danger**: Deletes ALL increments and docs without backup (unless you bypass warnings).
|
|
156
89
|
|
|
157
|
-
**
|
|
90
|
+
**Safe alternative**:
|
|
158
91
|
```bash
|
|
159
|
-
#
|
|
160
|
-
git restore .specweave/
|
|
161
|
-
|
|
162
|
-
# Verify restoration:
|
|
163
|
-
git status
|
|
92
|
+
specweave init . # Interactive, never deletes without confirmation
|
|
164
93
|
```
|
|
165
94
|
|
|
166
|
-
|
|
95
|
+
### 6. Increment Completion Validation
|
|
167
96
|
|
|
168
|
-
|
|
97
|
+
**NEVER** mark increment "completed" without:
|
|
98
|
+
1. All acceptance criteria checked (`- [x] **AC-...`)
|
|
99
|
+
2. All tasks completed
|
|
100
|
+
3. All tests passing
|
|
101
|
+
4. Coverage target met
|
|
169
102
|
|
|
170
|
-
|
|
103
|
+
**Always use**: `/specweave:done 0043` (validates before closing)
|
|
104
|
+
**Never**: Manual `metadata.json` edit (blocked by pre-commit hook)
|
|
171
105
|
|
|
172
|
-
|
|
106
|
+
### 7. Source of Truth: tasks.md and spec.md (CRITICAL!)
|
|
173
107
|
|
|
174
|
-
**
|
|
108
|
+
**THE MOST CRITICAL RULE**: Internal TODO lists are ONLY for tracking work during execution. The SOURCE OF TRUTH is ALWAYS:
|
|
109
|
+
1. **tasks.md** - Task completion status (`[x]` checkboxes)
|
|
110
|
+
2. **spec.md** - Acceptance criteria status (`[x]` checkboxes)
|
|
175
111
|
|
|
176
|
-
**
|
|
177
|
-
```bash
|
|
178
|
-
# ❌ EXTREMELY DANGEROUS (can delete entire test suite):
|
|
179
|
-
cd tests/integration
|
|
180
|
-
find . -maxdepth 1 -type d ... -exec rm -rf {} +
|
|
181
|
-
# Risk: Working directory confusion + no confirmation = catastrophic deletion
|
|
182
|
-
|
|
183
|
-
# ❌ DANGEROUS (no verification):
|
|
184
|
-
find tests/integration -type d -exec rm -rf {} +
|
|
185
|
-
# Risk: Too broad, deletes everything
|
|
186
|
-
|
|
187
|
-
# ❌ DANGEROUS (assumes pwd):
|
|
188
|
-
rm -rf tests/integration/*/
|
|
189
|
-
# Risk: If pwd is wrong, deletes unintended directories
|
|
190
|
-
```
|
|
112
|
+
**MANDATORY Workflow When Using TodoWrite Tool**:
|
|
191
113
|
|
|
192
|
-
**SAFE APPROACH** (MANDATORY for test cleanup):
|
|
193
|
-
```bash
|
|
194
|
-
# ✅ STEP 1: Verify working directory (ALWAYS FIRST!)
|
|
195
|
-
pwd
|
|
196
|
-
# Must output: /Users/antonabyzov/Projects/github/specweave
|
|
197
|
-
|
|
198
|
-
# ✅ STEP 2: DRY RUN (list only, NO deletion)
|
|
199
|
-
find tests/integration -maxdepth 1 -type d \
|
|
200
|
-
! -name "integration" \
|
|
201
|
-
! -name "core" ! -name "features" ! -name "external-tools" ! -name "generators" \
|
|
202
|
-
-print
|
|
203
|
-
# Review output MANUALLY before proceeding
|
|
204
|
-
|
|
205
|
-
# ✅ STEP 3: Count directories to delete
|
|
206
|
-
find tests/integration -maxdepth 1 -type d \
|
|
207
|
-
! -name "integration" \
|
|
208
|
-
! -name "core" ! -name "features" ! -name "external-tools" ! -name "generators" \
|
|
209
|
-
-print | wc -l
|
|
210
|
-
# Verify count matches expectations
|
|
211
|
-
|
|
212
|
-
# ✅ STEP 4: Manual confirmation (REQUIRED)
|
|
213
|
-
echo "About to delete XX directories. Type 'DELETE' to confirm:"
|
|
214
|
-
read confirmation
|
|
215
|
-
if [ "$confirmation" != "DELETE" ]; then
|
|
216
|
-
echo "Cancelled"
|
|
217
|
-
exit 1
|
|
218
|
-
fi
|
|
219
|
-
|
|
220
|
-
# ✅ STEP 5: Execute deletion (ONLY after all checks pass)
|
|
221
|
-
find tests/integration -maxdepth 1 -type d \
|
|
222
|
-
! -name "integration" \
|
|
223
|
-
! -name "core" ! -name "features" ! -name "external-tools" ! -name "generators" \
|
|
224
|
-
-exec rm -rf {} +
|
|
225
|
-
|
|
226
|
-
# ✅ STEP 6: Verify results
|
|
227
|
-
ls tests/integration/
|
|
228
|
-
find tests/integration -name "*.test.ts" | wc -l
|
|
229
|
-
|
|
230
|
-
# ✅ STEP 7: Run tests (MANDATORY)
|
|
231
|
-
npm run test:integration
|
|
232
114
|
```
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
4. ✅ **ALWAYS** require manual confirmation for deletion
|
|
239
|
-
5. ✅ **ALWAYS** verify results after deletion
|
|
240
|
-
6. ✅ **ALWAYS** run tests after structural changes
|
|
241
|
-
7. ✅ **NEVER** use `rm -rf` without multiple safety checks
|
|
242
|
-
|
|
243
|
-
**WHY THIS MATTERS**:
|
|
244
|
-
- 🔴 One wrong command = entire test suite deleted
|
|
245
|
-
- 🔴 213 unsafe `process.cwd()` patterns exist in tests (increment 0042 audit)
|
|
246
|
-
- 🔴 Working directory confusion is COMMON
|
|
247
|
-
- 🔴 Recovery requires git restore (assumes uncommitted changes)
|
|
248
|
-
- 🔴 If changes committed, recovery requires time-consuming rollback
|
|
249
|
-
|
|
250
|
-
**LESSONS FROM INCIDENT 0042**:
|
|
251
|
-
1. **Dry-run is NOT optional** - Always list before deleting
|
|
252
|
-
2. **Working directory matters** - Verify pwd FIRST
|
|
253
|
-
3. **Confirmation prevents accidents** - Require manual "DELETE" confirmation
|
|
254
|
-
4. **Test after changes** - Structural changes can break tests
|
|
255
|
-
5. **Incremental commits** - Commit after each phase (easier rollback)
|
|
256
|
-
|
|
257
|
-
**IF CATASTROPHIC DELETION OCCURS**:
|
|
258
|
-
```bash
|
|
259
|
-
# Immediately restore from git (if not committed):
|
|
260
|
-
git restore tests/
|
|
261
|
-
|
|
262
|
-
# If committed, restore from previous commit:
|
|
263
|
-
git log --oneline -- tests/
|
|
264
|
-
git checkout <previous-commit-hash> -- tests/
|
|
265
|
-
|
|
266
|
-
# Verify restoration:
|
|
267
|
-
find tests -name "*.test.ts" | wc -l
|
|
268
|
-
npm run test:all
|
|
115
|
+
For EVERY task marked complete in internal TODO:
|
|
116
|
+
1. ✅ Mark task as completed in internal TODO
|
|
117
|
+
2. ⚠️ IMMEDIATELY update tasks.md checkbox: `[ ] pending` → `[x] completed`
|
|
118
|
+
3. ⚠️ IMMEDIATELY update spec.md AC checkbox: `[ ]` → `[x]`
|
|
119
|
+
4. ✅ Verify both files updated BEFORE moving to next task
|
|
269
120
|
```
|
|
270
121
|
|
|
271
|
-
**
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
122
|
+
**Example of CORRECT workflow**:
|
|
123
|
+
```typescript
|
|
124
|
+
// Step 1: Complete the work
|
|
125
|
+
await createIntegrationTest();
|
|
275
126
|
|
|
276
|
-
|
|
127
|
+
// Step 2: Update internal TODO
|
|
128
|
+
TodoWrite([{task: "T-013", status: "completed"}]);
|
|
277
129
|
|
|
278
|
-
|
|
130
|
+
// Step 3: IMMEDIATELY update tasks.md (NEVER skip this!)
|
|
131
|
+
Edit("tasks.md", "**Status**: [ ] pending", "**Status**: [x] completed");
|
|
279
132
|
|
|
280
|
-
|
|
133
|
+
// Step 4: IMMEDIATELY update spec.md ACs
|
|
134
|
+
Edit("spec.md", "- [ ] **AC-US1-01**", "- [x] **AC-US1-01**");
|
|
281
135
|
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
**THE DANGER**:
|
|
285
|
-
```bash
|
|
286
|
-
# ❌ DANGEROUS (deletes ALL increments and docs):
|
|
287
|
-
specweave init . --force
|
|
288
|
-
|
|
289
|
-
# What --force actually does:
|
|
290
|
-
# 1. Skips all confirmation prompts
|
|
291
|
-
# 2. AUTOMATICALLY DELETES .specweave/ entirely
|
|
292
|
-
# 3. Loses all increments, docs, and history
|
|
293
|
-
# 4. No backup unless you create one manually
|
|
136
|
+
// Step 5: Move to next task
|
|
294
137
|
```
|
|
295
138
|
|
|
296
|
-
|
|
297
|
-
```
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
139
|
+
**❌ CRITICAL ERROR - Never Do This**:
|
|
140
|
+
```typescript
|
|
141
|
+
// ❌ WRONG: Marking TODO as complete WITHOUT updating source files
|
|
142
|
+
TodoWrite([
|
|
143
|
+
{task: "T-013", status: "completed"}, // ❌ Only internal tracking
|
|
144
|
+
{task: "T-014", status: "completed"}, // ❌ Only internal tracking
|
|
145
|
+
{task: "T-015", status: "completed"} // ❌ Only internal tracking
|
|
146
|
+
]);
|
|
147
|
+
// tasks.md still shows `[ ] pending` → DESYNC!
|
|
148
|
+
// This is a CRITICAL VIOLATION!
|
|
304
149
|
```
|
|
305
150
|
|
|
306
|
-
**
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
- ✅ ALWAYS requires confirmation (even in force mode)
|
|
312
|
-
- 📦 Automatic backup created before deletion
|
|
313
|
-
- 🔒 Pre-commit hook blocks accidental commits
|
|
151
|
+
**Pre-Closure Validation** (MANDATORY before `/specweave:done`):
|
|
152
|
+
```bash
|
|
153
|
+
# 1. Verify ALL tasks marked in tasks.md
|
|
154
|
+
grep "^\*\*Status\*\*:" tasks.md | grep -c "\[x\] completed"
|
|
155
|
+
# Output MUST equal total_tasks in frontmatter
|
|
314
156
|
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
3. Or: `specweave init . --force` (requires confirmation + creates auto-backup)
|
|
157
|
+
# 2. Verify ALL ACs checked in spec.md
|
|
158
|
+
grep -c "^- \[x\] \*\*AC-" spec.md
|
|
159
|
+
# Output MUST equal total ACs
|
|
319
160
|
|
|
320
|
-
|
|
161
|
+
# 3. Only then close increment
|
|
162
|
+
/specweave:done 0044
|
|
163
|
+
```
|
|
321
164
|
|
|
322
|
-
|
|
165
|
+
**Why This Matters**:
|
|
166
|
+
- Internal TODO is ephemeral (lost between sessions)
|
|
167
|
+
- tasks.md is permanent source of truth
|
|
168
|
+
- spec.md is contract with stakeholders
|
|
169
|
+
- Desync = broken promises to users/team
|
|
323
170
|
|
|
324
|
-
|
|
171
|
+
**Incident Reference**: 2025-11-19 - Increment 0044 was incorrectly closed with tasks.md showing `[ ] pending` while internal TODO showed "completed". This violated SpecWeave's core principle. See `.specweave/increments/0044-integration-testing-status-hooks/reports/INCIDENT-SOURCE-OF-TRUTH-VIOLATION.md` for full post-mortem.
|
|
325
172
|
|
|
326
|
-
|
|
327
|
-
- **Claude Code** (Recommended): Native support via plugins, hooks, MCP
|
|
328
|
-
- **Cursor**: Partial support via AGENTS.md compilation
|
|
329
|
-
- **Other tools** (Copilot, ChatGPT, Gemini): Basic support via AGENTS.md
|
|
173
|
+
### 8. NEVER Use `console.*` in Production Code
|
|
330
174
|
|
|
331
|
-
|
|
175
|
+
**Rule**: ALL `src/` code MUST use logger abstraction, NEVER `console.log/error/warn`.
|
|
332
176
|
|
|
333
|
-
|
|
177
|
+
**Why**: `console.*` pollutes test output even when errors are expected and properly handled.
|
|
334
178
|
|
|
335
|
-
|
|
179
|
+
**Use logger injection**:
|
|
180
|
+
```typescript
|
|
181
|
+
import { Logger, consoleLogger } from '../../utils/logger.js';
|
|
336
182
|
|
|
337
|
-
|
|
183
|
+
export class MyClass {
|
|
184
|
+
private logger: Logger;
|
|
338
185
|
|
|
339
|
-
|
|
186
|
+
constructor(options: { logger?: Logger } = {}) {
|
|
187
|
+
this.logger = options.logger ?? consoleLogger;
|
|
188
|
+
}
|
|
340
189
|
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
/specweave:done # Close increment (with validation)
|
|
190
|
+
doSomething() {
|
|
191
|
+
this.logger.log('Info message');
|
|
192
|
+
this.logger.error('Error message', error);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
347
195
|
```
|
|
348
196
|
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
1. ✅ All acceptance criteria checked (`- [x] **AC-...`)
|
|
353
|
-
2. ✅ All tasks completed (`**Status**: [x] completed`)
|
|
354
|
-
3. ✅ All tests passing (unit, integration, E2E)
|
|
355
|
-
4. ✅ Coverage target met (`npm run test:coverage`)
|
|
356
|
-
|
|
357
|
-
**Automated Protection**:
|
|
358
|
-
- `/specweave:done` runs `IncrementCompletionValidator` before PM validation
|
|
359
|
-
- Pre-commit hook blocks commits with invalid completion status
|
|
360
|
-
- CI/CD validates completion on pull requests
|
|
361
|
-
|
|
362
|
-
**Manual Protection** (if editing metadata.json directly):
|
|
363
|
-
```bash
|
|
364
|
-
# ❌ NEVER DO THIS - Manual metadata edit without validation
|
|
365
|
-
vim .specweave/increments/0043-spec-md-desync-fix/metadata.json
|
|
366
|
-
# Change "status": "active" → "completed"
|
|
367
|
-
git commit -m "Complete increment" # Will be BLOCKED by pre-commit hook
|
|
197
|
+
**In tests, use `silentLogger`**:
|
|
198
|
+
```typescript
|
|
199
|
+
import { silentLogger } from '../../src/utils/logger.js';
|
|
368
200
|
|
|
369
|
-
|
|
370
|
-
/specweave:done 0043 # Validates ACs, tasks, tests, docs before closing
|
|
201
|
+
const instance = new MyClass({ logger: silentLogger });
|
|
371
202
|
```
|
|
372
203
|
|
|
373
|
-
**
|
|
204
|
+
**Protection**: Code review + search before commit:
|
|
374
205
|
```bash
|
|
375
|
-
/
|
|
376
|
-
|
|
377
|
-
❌ CANNOT CLOSE INCREMENT - Automated validation failed
|
|
378
|
-
|
|
379
|
-
• 17 acceptance criteria still open
|
|
380
|
-
• 13 tasks still pending
|
|
381
|
-
|
|
382
|
-
Fix these issues before running /specweave:done again
|
|
206
|
+
# Check for console.* in src/ before committing:
|
|
207
|
+
git diff --cached --name-only | grep '^src/.*\.ts$' | xargs grep -n 'console\.' 2>/dev/null
|
|
383
208
|
```
|
|
384
209
|
|
|
385
|
-
|
|
386
|
-
- **False completion** → Status line shows wrong increment
|
|
387
|
-
- **GitHub sync broken** → Issues marked closed with open work
|
|
388
|
-
- **Data integrity violation** → Source of truth is inconsistent
|
|
389
|
-
- **Stakeholder confusion** → External tools show wrong status
|
|
210
|
+
### 9. Coding Standards
|
|
390
211
|
|
|
391
|
-
**
|
|
392
|
-
|
|
393
|
-
/specweave:pause 0002 --reason="..." # Pause increment
|
|
394
|
-
/specweave:resume 0002 # Resume paused
|
|
395
|
-
/specweave:abandon 0002 # Abandon incomplete
|
|
396
|
-
```
|
|
212
|
+
**Full standards**: `.specweave/docs/internal/governance/coding-standards.md`
|
|
213
|
+
**Auto-discovery**: Runs during brownfield analysis or `/specweave:analyze-standards`
|
|
397
214
|
|
|
398
|
-
**
|
|
399
|
-
```bash
|
|
400
|
-
/specweave:archive 0031 # Archive specific
|
|
401
|
-
/specweave:archive --keep-last 10 # Archive old work
|
|
402
|
-
/specweave:restore 0031 # Restore from archive
|
|
403
|
-
```
|
|
215
|
+
**Critical rules (enforced during code generation)**:
|
|
404
216
|
|
|
405
|
-
**
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
217
|
+
1. ✅ **NEVER use `console.*`** - Use logger abstraction (already enforced above)
|
|
218
|
+
2. ✅ **ALWAYS import with `.js` extensions** - Required for ESM (already enforced in Build section)
|
|
219
|
+
3. ✅ **Test files MUST use `.test.ts`** suffix, never `.spec.ts` (already enforced in Testing section)
|
|
220
|
+
4. **Avoid `any` type** - Use specific types or generics
|
|
221
|
+
5. **Functions < 50 lines** (ideal), < 100 lines (max)
|
|
222
|
+
6. **Use custom error types**, not generic Error
|
|
223
|
+
7. **Comment "why" not "what"**
|
|
224
|
+
8. **No hardcoded secrets** - Use environment variables
|
|
225
|
+
9. **No N+1 queries** - Batch database operations
|
|
226
|
+
10. **Naming**: camelCase (vars), PascalCase (classes), UPPER_SNAKE_CASE (constants)
|
|
410
227
|
|
|
411
|
-
**
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
228
|
+
**Auto-discovery features**:
|
|
229
|
+
- **Brownfield projects**: Standards auto-detected during project analysis
|
|
230
|
+
- **Manual analysis**: `/specweave:analyze-standards` - Generate comprehensive standards report
|
|
231
|
+
- **Drift detection**: `/specweave:analyze-standards --drift` - Check compliance with declared standards
|
|
232
|
+
- **Update standards**: `/specweave:analyze-standards --update` - Update official standards from analysis
|
|
416
233
|
|
|
417
|
-
**
|
|
234
|
+
**How it works**:
|
|
235
|
+
1. Scans codebase (src/**/*.ts) for naming patterns, import styles, function characteristics
|
|
236
|
+
2. Parses ESLint, Prettier, TypeScript configs for enforced rules
|
|
237
|
+
3. Analyzes existing CLAUDE.md, CONTRIBUTING.md for declared standards
|
|
238
|
+
4. Generates evidence-based standards with confidence levels (90%+ = HIGH confidence)
|
|
239
|
+
5. Detects anti-patterns: hardcoded secrets, large files (>500 lines), missing error handling
|
|
240
|
+
6. Outputs to `.specweave/docs/internal/governance/coding-standards-analysis.md`
|
|
241
|
+
|
|
242
|
+
**Note**: Most standards are enforced by ESLint/Prettier. This list focuses on SpecWeave-specific rules and patterns that can't be auto-fixed by linters.
|
|
418
243
|
|
|
419
244
|
---
|
|
420
245
|
|
|
421
246
|
## Project Structure
|
|
422
247
|
|
|
423
|
-
### Source of Truth Principle
|
|
424
|
-
|
|
425
248
|
```
|
|
426
|
-
src/ # TypeScript code
|
|
427
|
-
plugins/ #
|
|
428
|
-
├── specweave/ # Core plugin
|
|
249
|
+
src/ # TypeScript code (compiled to dist/)
|
|
250
|
+
plugins/ # Claude Code components (skills, agents, commands, hooks)
|
|
251
|
+
├── specweave/ # Core plugin
|
|
429
252
|
└── specweave-*/ # Optional plugins (GitHub, JIRA, etc.)
|
|
430
253
|
.specweave/ # Framework data (increments, docs, logs)
|
|
431
254
|
```
|
|
432
255
|
|
|
433
|
-
**
|
|
434
|
-
-
|
|
435
|
-
-
|
|
436
|
-
-
|
|
437
|
-
-
|
|
438
|
-
-
|
|
439
|
-
|
|
440
|
-
**For complete structure**: See `README.md`
|
|
256
|
+
**Rules**:
|
|
257
|
+
- `src/` = TypeScript ONLY
|
|
258
|
+
- ALL skills/agents/commands/hooks = `plugins/`
|
|
259
|
+
- Marketplace = GLOBAL via CLI
|
|
260
|
+
- NEVER mix `*.ts` and `SKILL.md` in same directory
|
|
261
|
+
- NEVER create files in project root
|
|
441
262
|
|
|
442
263
|
---
|
|
443
264
|
|
|
444
|
-
##
|
|
445
|
-
|
|
446
|
-
### Core Plugin (Always Auto-Loaded)
|
|
447
|
-
|
|
448
|
-
**Plugin**: `specweave` - The essential SpecWeave plugin loaded in every project:
|
|
449
|
-
- **Skills**: 9 skills (increment-planner, tdd-workflow, spec-generator, etc.)
|
|
450
|
-
- **Agents**: 22 agents (PM, Architect, Tech Lead, + 19 specialized)
|
|
451
|
-
- **Commands**: 22 commands (/specweave:increment, /specweave:do, etc.)
|
|
452
|
-
- **Hooks**: 8 lifecycle hooks
|
|
453
|
-
- **Size**: ~12K tokens
|
|
454
|
-
|
|
455
|
-
### Available Plugins
|
|
456
|
-
|
|
457
|
-
All plugins are auto-installed during `specweave init`. Skills activate based on context keywords.
|
|
458
|
-
|
|
459
|
-
**Plugin List**: `ls plugins/` or `/plugin list --installed`
|
|
460
|
-
|
|
461
|
-
**Example plugins**:
|
|
462
|
-
- `specweave` - Core (increment lifecycle, living docs)
|
|
463
|
-
- `specweave-github` - GitHub Issues sync
|
|
464
|
-
- `specweave-{frontend|backend|infrastructure}` - Tech stacks
|
|
465
|
-
- `specweave-{ml|payments}` - Domain-specific
|
|
466
|
-
|
|
467
|
-
### Plugin Installation
|
|
265
|
+
## Development Workflow
|
|
468
266
|
|
|
469
|
-
|
|
470
|
-
1. Registers marketplace: `claude plugin marketplace add anton-abyzov/specweave`
|
|
471
|
-
2. Installs all plugins via Claude CLI
|
|
472
|
-
3. Marketplace is GLOBAL (persists across projects)
|
|
267
|
+
### Core Commands
|
|
473
268
|
|
|
474
|
-
|
|
269
|
+
```bash
|
|
270
|
+
# Primary workflow
|
|
271
|
+
/specweave:increment "feature" # Plan new work
|
|
272
|
+
/specweave:do # Execute tasks
|
|
273
|
+
/specweave:progress # Check status
|
|
274
|
+
/specweave:done # Close (validates ACs, tasks, tests)
|
|
475
275
|
|
|
476
|
-
|
|
276
|
+
# State management
|
|
277
|
+
/specweave:pause 0002 --reason="..."
|
|
278
|
+
/specweave:resume 0002
|
|
279
|
+
/specweave:abandon 0002
|
|
477
280
|
|
|
478
|
-
|
|
281
|
+
# Quality
|
|
282
|
+
/specweave:validate 0001
|
|
283
|
+
/specweave:qa 0001
|
|
479
284
|
|
|
480
|
-
|
|
481
|
-
-
|
|
482
|
-
-
|
|
483
|
-
|
|
285
|
+
# Documentation
|
|
286
|
+
/specweave:sync-docs update
|
|
287
|
+
/specweave:sync-tasks
|
|
288
|
+
```
|
|
484
289
|
|
|
485
|
-
|
|
290
|
+
### Local Development Setup
|
|
486
291
|
|
|
487
292
|
```bash
|
|
488
|
-
# 1. Clone and install
|
|
293
|
+
# 1. Clone and install
|
|
489
294
|
git clone https://github.com/YOUR_USERNAME/specweave.git
|
|
490
295
|
cd specweave
|
|
491
296
|
npm install
|
|
492
297
|
|
|
493
|
-
# 2. Create
|
|
494
|
-
# ⚠️ IMPORTANT: Use absolute path, NOT $PWD (see ultrathink report for details)
|
|
298
|
+
# 2. Create symlink (CRITICAL!)
|
|
495
299
|
mkdir -p ~/.claude/plugins/marketplaces
|
|
496
|
-
rm -rf ~/.claude/plugins/marketplaces/specweave
|
|
300
|
+
rm -rf ~/.claude/plugins/marketplaces/specweave
|
|
497
301
|
ln -s "$(pwd)" ~/.claude/plugins/marketplaces/specweave
|
|
498
302
|
|
|
499
|
-
# 3. Verify setup
|
|
303
|
+
# 3. Verify setup
|
|
500
304
|
bash .specweave/increments/0043-spec-md-desync-fix/scripts/verify-dev-setup.sh
|
|
501
|
-
# Must show: ✅ ALL CHECKS PASSED!
|
|
502
|
-
# If verification fails, see ultrathink report:
|
|
503
|
-
# .specweave/increments/0043-spec-md-desync-fix/reports/ULTRATHINK-HOOK-EXECUTION-ERRORS-ROOT-CAUSE-ANALYSIS-2025-11-18.md
|
|
504
305
|
|
|
505
|
-
# 4. Install git hooks
|
|
306
|
+
# 4. Install git hooks
|
|
506
307
|
bash scripts/install-git-hooks.sh
|
|
507
308
|
```
|
|
508
309
|
|
|
509
|
-
**
|
|
510
|
-
|
|
511
|
-
Claude Code's hook execution system looks for hooks in `~/.claude/plugins/marketplaces/specweave/`, NOT in your local repo.
|
|
512
|
-
|
|
513
|
-
**⚠️ CRITICAL: Directory vs Symlink Issue**
|
|
514
|
-
|
|
515
|
-
The marketplace path MUST be a **symlink**, NOT a **directory**:
|
|
516
|
-
- ✅ **Symlink** (`lrwxr-xr-x`): All hook changes immediately reflected
|
|
517
|
-
- ❌ **Directory** (`drwxr-xr-x`): Stale copy, hooks fail with "No such file or directory"
|
|
518
|
-
|
|
519
|
-
**Without the symlink:**
|
|
520
|
-
- ❌ All post-task-completion hooks fail with "No such file or directory"
|
|
521
|
-
- ❌ Status line doesn't update automatically
|
|
522
|
-
- ❌ Living docs don't sync after task completion
|
|
523
|
-
- ❌ Increment metadata doesn't update
|
|
524
|
-
- ❌ You'll waste hours debugging hook errors
|
|
525
|
-
|
|
526
|
-
**Root Cause Analysis**: See comprehensive ultrathink report at:
|
|
527
|
-
`.specweave/increments/0043-spec-md-desync-fix/reports/ULTRATHINK-HOOK-EXECUTION-ERRORS-ROOT-CAUSE-ANALYSIS-2025-11-18.md`
|
|
528
|
-
|
|
529
|
-
**Detailed Setup (if Quick Setup fails):**
|
|
530
|
-
|
|
531
|
-
```bash
|
|
532
|
-
# 1. Remove any existing marketplace installation
|
|
533
|
-
rm -rf ~/.claude/plugins/marketplaces/specweave
|
|
534
|
-
|
|
535
|
-
# 2. Create symlink to your local SpecWeave repository
|
|
536
|
-
ln -s /path/to/your/specweave/repo ~/.claude/plugins/marketplaces/specweave
|
|
537
|
-
|
|
538
|
-
# Example:
|
|
539
|
-
ln -s ~/Projects/github/specweave ~/.claude/plugins/marketplaces/specweave
|
|
540
|
-
|
|
541
|
-
# 3. Verify symlink is correct
|
|
542
|
-
readlink ~/.claude/plugins/marketplaces/specweave
|
|
543
|
-
# Should output: /path/to/your/specweave/repo
|
|
544
|
-
|
|
545
|
-
# 4. Verify hooks are accessible
|
|
546
|
-
test -f ~/.claude/plugins/marketplaces/specweave/plugins/specweave/hooks/post-task-completion.sh && \
|
|
547
|
-
echo "✅ Hooks accessible" || echo "❌ Setup failed"
|
|
548
|
-
|
|
549
|
-
# 5. Run automated verification
|
|
550
|
-
bash .specweave/increments/0043-spec-md-desync-fix/scripts/verify-dev-setup.sh
|
|
551
|
-
```
|
|
552
|
-
|
|
553
|
-
**Verification Output:**
|
|
554
|
-
|
|
555
|
-
```
|
|
556
|
-
✅ ALL CHECKS PASSED! Local development setup is correct.
|
|
557
|
-
You can now use TodoWrite and other tools without hook errors.
|
|
558
|
-
```
|
|
559
|
-
|
|
560
|
-
**If you see "Plugin not found" errors:**
|
|
561
|
-
|
|
562
|
-
This means the plugin registry is out of sync. Fix it:
|
|
563
|
-
|
|
310
|
+
**If "Plugin not found" errors**:
|
|
564
311
|
```bash
|
|
565
|
-
# 1. Backup current registry
|
|
566
|
-
cp ~/.claude/plugins/installed_plugins.json ~/.claude/plugins/installed_plugins.json.backup
|
|
567
|
-
|
|
568
|
-
# 2. Clear registry (forces rediscovery)
|
|
569
312
|
echo '{"version": 1, "plugins": {}}' > ~/.claude/plugins/installed_plugins.json
|
|
570
|
-
|
|
571
|
-
# 3. Update marketplace
|
|
572
313
|
claude plugin marketplace update specweave
|
|
573
|
-
|
|
574
|
-
# 4. Restart Claude Code
|
|
575
|
-
# All 25 plugins will be rediscovered from your local repo
|
|
576
|
-
```
|
|
577
|
-
|
|
578
|
-
**Verification:**
|
|
579
|
-
|
|
580
|
-
```bash
|
|
581
|
-
# Check symlink target
|
|
582
|
-
readlink ~/.claude/plugins/marketplaces/specweave
|
|
583
|
-
# Should output: /path/to/your/specweave/repo
|
|
584
|
-
|
|
585
|
-
# Check all plugins are accessible
|
|
586
|
-
ls ~/.claude/plugins/marketplaces/specweave/plugins/
|
|
587
|
-
# Should list: specweave, specweave-github, specweave-jira, etc.
|
|
588
|
-
```
|
|
589
|
-
|
|
590
|
-
**Why This Matters:**
|
|
591
|
-
|
|
592
|
-
Without the symlink, Claude Code will try to execute hooks from a non-existent location:
|
|
593
314
|
```
|
|
594
|
-
❌ Plugin hook error: /bin/sh:
|
|
595
|
-
~/.claude/plugins/marketplaces/specweave/plugins/specweave/hooks/user-prompt-submit.sh:
|
|
596
|
-
No such file or directory
|
|
597
|
-
```
|
|
598
|
-
|
|
599
|
-
**Troubleshooting:**
|
|
600
|
-
|
|
601
|
-
If you see "Plugin not found in marketplace 'specweave'" errors:
|
|
602
|
-
1. Check symlink exists: `ls -la ~/.claude/plugins/marketplaces/specweave`
|
|
603
|
-
2. Verify it points to your repo: `readlink ~/.claude/plugins/marketplaces/specweave`
|
|
604
|
-
3. Recreate symlink if needed (see setup instructions above)
|
|
605
|
-
|
|
606
|
-
**What NOT to Do:**
|
|
607
|
-
|
|
608
|
-
- ❌ Don't copy the repository - use a symlink
|
|
609
|
-
- ❌ Don't use relative paths in symlink - use absolute paths
|
|
610
|
-
- ❌ Don't register the marketplace via `claude plugin marketplace add` - symlink is enough for local dev
|
|
611
|
-
|
|
612
|
-
---
|
|
613
|
-
|
|
614
|
-
## Multi-Tool Support via Adapters
|
|
615
|
-
|
|
616
|
-
SpecWeave supports multiple AI coding tools through an adapter system. Tool selection happens during `specweave init`.
|
|
617
|
-
|
|
618
|
-
**Adapter Architecture**:
|
|
619
|
-
- **Location**: `src/adapters/` (interface, loader, tool-specific implementations)
|
|
620
|
-
- **Selection**: Auto-detected or via `--adapter` flag
|
|
621
|
-
- **Files**: Tool-specific files (`.cursorrules`, `AGENTS.md`, etc.)
|
|
622
|
-
|
|
623
|
-
**Supported Tools**:
|
|
624
|
-
|
|
625
|
-
| Tool | Automation Level | Implementation | Status |
|
|
626
|
-
|------|------------------|----------------|--------|
|
|
627
|
-
| **Claude Code** | Full | Native plugins (no adapter) | ✅ Recommended |
|
|
628
|
-
| **Cursor** | Partial | AGENTS.md compilation | ✅ Supported |
|
|
629
|
-
| **Generic** | Basic | AGENTS.md static file | ✅ Supported |
|
|
630
|
-
|
|
631
|
-
**Key Differences**:
|
|
632
|
-
- **Claude Code**: No adapter needed - uses native plugin system
|
|
633
|
-
- **Cursor/Generic**: Require compilation step to generate AGENTS.md
|
|
634
|
-
- **All tools**: Share same `.specweave/` data structure
|
|
635
|
-
|
|
636
|
-
**For contributors**: Adapter code is in `src/adapters/`. Tests in `tests/unit/adapter-loader.test.ts`.
|
|
637
315
|
|
|
638
316
|
---
|
|
639
317
|
|
|
640
|
-
##
|
|
641
|
-
|
|
642
|
-
See [.github/CONTRIBUTING.md](.github/CONTRIBUTING.md#core-development-principles) for:
|
|
643
|
-
- Source of Truth Discipline
|
|
644
|
-
- Documentation = Code
|
|
645
|
-
- Testing Requirements
|
|
646
|
-
- Incremental Development
|
|
647
|
-
- Multi-Tool Support
|
|
648
|
-
|
|
649
|
-
---
|
|
650
|
-
|
|
651
|
-
## Recent Architectural Enhancements (v0.18.3+)
|
|
652
|
-
|
|
653
|
-
### Project-Specific Tasks in User Stories
|
|
654
|
-
|
|
655
|
-
**New in v0.18.3**: User stories now include project-specific checkable task lists instead of just links to increment tasks.
|
|
656
|
-
|
|
657
|
-
**Key Changes**:
|
|
658
|
-
1. **TaskProjectSpecificGenerator** (`src/core/living-docs/task-project-specific-generator.ts`):
|
|
659
|
-
- Filters increment tasks by User Story ID (via AC-IDs)
|
|
660
|
-
- Optional project keyword filtering (backend vs frontend)
|
|
661
|
-
- Preserves completion status from increment tasks.md
|
|
662
|
-
|
|
663
|
-
2. **User Story File Format** - New `## Tasks` section:
|
|
664
|
-
```markdown
|
|
665
|
-
## Tasks
|
|
318
|
+
## Build & Test
|
|
666
319
|
|
|
667
|
-
|
|
668
|
-
- [x] **T-003**: Add DB migration (completed)
|
|
320
|
+
### Build
|
|
669
321
|
|
|
670
|
-
|
|
322
|
+
```bash
|
|
323
|
+
npm run rebuild # Clean + build (use this during development)
|
|
324
|
+
npm run build # Compile TypeScript
|
|
325
|
+
npm run clean # Remove dist/
|
|
671
326
|
```
|
|
672
327
|
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
**Benefits**:
|
|
679
|
-
- **Project Isolation**: Backend tasks ≠ Frontend tasks
|
|
680
|
-
- **Traceability**: Each user story explicitly lists its tasks
|
|
681
|
-
- **GitHub UX**: Checkable task lists in issues
|
|
682
|
-
- **Completion Tracking**: Status preserved from increment
|
|
328
|
+
**Critical**: Always import with `.js` extensions:
|
|
329
|
+
```typescript
|
|
330
|
+
// ✅ CORRECT
|
|
331
|
+
import { foo } from './bar.js';
|
|
683
332
|
|
|
684
|
-
|
|
333
|
+
// ❌ WRONG
|
|
334
|
+
import { foo } from './bar';
|
|
685
335
|
```
|
|
686
|
-
Increment tasks.md (All tasks, source of truth)
|
|
687
|
-
↓
|
|
688
|
-
TaskProjectSpecificGenerator (Filters by US + Project)
|
|
689
|
-
↓
|
|
690
|
-
User Story ## Tasks Section (Project-specific checkboxes)
|
|
691
|
-
↓
|
|
692
|
-
GitHub Issue (Checkable task list for stakeholders)
|
|
693
|
-
```
|
|
694
|
-
|
|
695
|
-
**See Also**:
|
|
696
|
-
- Implementation: `.specweave/increments/0034-github-ac-checkboxes-fix/reports/PROJECT-SPECIFIC-TASKS-IMPLEMENTATION-COMPLETE.md`
|
|
697
|
-
- Architecture: `.specweave/increments/0034-github-ac-checkboxes-fix/reports/ULTRATHINK-PROJECT-SPECIFIC-TASKS-ARCHITECTURE.md`
|
|
698
|
-
|
|
699
|
-
---
|
|
700
|
-
|
|
701
|
-
## Build & Test
|
|
702
336
|
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
```bash
|
|
706
|
-
# ALWAYS use clean build during development (prevents TS5055 errors)
|
|
707
|
-
npm run rebuild # Clean + build (RECOMMENDED)
|
|
708
|
-
|
|
709
|
-
# Or manual steps:
|
|
710
|
-
npm run clean # Remove dist/ folder
|
|
711
|
-
npm run build # Compile TypeScript
|
|
712
|
-
```
|
|
337
|
+
**Fix missing extensions**: `node scripts/fix-js-extensions.js`
|
|
713
338
|
|
|
714
339
|
### Testing
|
|
715
340
|
|
|
716
|
-
**
|
|
341
|
+
**Framework**: Vitest (migrated from Jest 2025-11-17)
|
|
717
342
|
|
|
718
343
|
```bash
|
|
719
|
-
npm test # Smoke tests
|
|
720
|
-
npm run test:unit # Unit tests
|
|
721
|
-
npm run test:integration # Integration tests
|
|
344
|
+
npm test # Smoke tests
|
|
345
|
+
npm run test:unit # Unit tests
|
|
346
|
+
npm run test:integration # Integration tests
|
|
722
347
|
npm run test:e2e # E2E tests (Playwright)
|
|
723
348
|
npm run test:all # All tests
|
|
724
349
|
npm run test:coverage # Coverage report
|
|
725
350
|
```
|
|
726
351
|
|
|
727
|
-
**
|
|
728
|
-
-
|
|
729
|
-
-
|
|
730
|
-
-
|
|
731
|
-
- ✅ Native import.meta.url support
|
|
732
|
-
- ✅ Modern, actively maintained
|
|
733
|
-
|
|
734
|
-
**Test Organization** (4 categories):
|
|
735
|
-
- `tests/unit/` - Pure logic tests (no I/O) - **Vitest**
|
|
736
|
-
- `tests/plugin-validation/` - Plugin structure contracts
|
|
737
|
-
- `tests/integration/` - 4 semantic categories - **Vitest**:
|
|
738
|
-
- `external-tools/` - GitHub, JIRA, ADO, Kafka sync
|
|
739
|
-
- `core/` - Core framework + workflows
|
|
740
|
-
- `generators/` - Code generation (frontend, backend, ML)
|
|
741
|
-
- `features/` - Feature plugins (Figma, i18n, diagrams, etc.)
|
|
742
|
-
- `tests/e2e/` - Full user scenarios - **Playwright**
|
|
743
|
-
|
|
744
|
-
**Test Naming Convention** (standardized 2025-11-18):
|
|
745
|
-
- ✅ ALL tests use `.test.ts` extension (unit, integration, E2E)
|
|
746
|
-
- ❌ NEVER use `.spec.ts` extension (deprecated)
|
|
747
|
-
- **Why**: Consistent glob patterns, simpler test discovery, aligned with Vitest conventions
|
|
748
|
-
|
|
749
|
-
**Writing Tests**:
|
|
750
|
-
```typescript
|
|
751
|
-
// Import from vitest (NOT jest)
|
|
752
|
-
import { describe, it, expect, beforeEach, vi } from 'vitest';
|
|
753
|
-
|
|
754
|
-
// Mocking
|
|
755
|
-
vi.mock('fs/promises');
|
|
756
|
-
const mockFn = vi.fn();
|
|
757
|
-
vi.clearAllMocks();
|
|
758
|
-
```
|
|
759
|
-
|
|
760
|
-
**Details**: `.specweave/docs/internal/architecture/TEST-ORGANIZATION-PROPOSAL.md`
|
|
761
|
-
|
|
762
|
-
### Test Isolation (CRITICAL - Prevents .specweave/ Deletion!)
|
|
763
|
-
|
|
764
|
-
**🚨 MANDATORY FOR ALL TESTS creating .specweave/ structures:**
|
|
765
|
-
|
|
766
|
-
**THE PROBLEM**: Tests using `process.cwd()` can accidentally delete the project `.specweave/` folder containing all your work!
|
|
767
|
-
|
|
768
|
-
**CORRECT PATTERN** (ALWAYS use this):
|
|
769
|
-
```typescript
|
|
770
|
-
import * as os from 'os';
|
|
771
|
-
import * as path from 'path';
|
|
772
|
-
|
|
773
|
-
// ✅ SAFE: Uses isolated temp directory
|
|
774
|
-
const testRoot = path.join(os.tmpdir(), 'test-name-' + Date.now());
|
|
775
|
-
```
|
|
776
|
-
|
|
777
|
-
**DANGEROUS PATTERN** (NEVER use this):
|
|
778
|
-
```typescript
|
|
779
|
-
// ❌ DANGER: Creates directories in project root!
|
|
780
|
-
const testRoot = path.join(process.cwd(), '.test-something');
|
|
781
|
-
const testPath = path.join(__dirname, '..', '.specweave', 'increments');
|
|
782
|
-
```
|
|
352
|
+
**Test structure**:
|
|
353
|
+
- `tests/unit/` - Pure logic (no I/O)
|
|
354
|
+
- `tests/integration/` - Organized by: `core/`, `external-tools/`, `generators/`, `features/`
|
|
355
|
+
- `tests/e2e/` - Full user scenarios
|
|
783
356
|
|
|
784
|
-
|
|
357
|
+
**Naming**: ALL tests use `.test.ts` (NEVER `.spec.ts`)
|
|
785
358
|
|
|
786
|
-
|
|
359
|
+
### Writing Tests
|
|
787
360
|
|
|
788
|
-
**CORRECT PATTERN** (vi.mocked() for type-safe mocks):
|
|
789
361
|
```typescript
|
|
362
|
+
// ✅ CORRECT
|
|
790
363
|
import { describe, it, expect, beforeEach, vi } from 'vitest';
|
|
791
364
|
import fs from 'fs-extra';
|
|
792
365
|
|
|
793
|
-
// Mock fs-extra BEFORE using it
|
|
794
366
|
vi.mock('fs-extra');
|
|
795
367
|
|
|
796
|
-
// Type-safe mocked functions
|
|
797
368
|
const mockReadFile = vi.mocked(fs.readFile);
|
|
798
|
-
const mockWriteFile = vi.mocked(fs.writeFile);
|
|
799
|
-
const mockExistsSync = vi.mocked(fs.existsSync);
|
|
800
369
|
|
|
801
370
|
beforeEach(() => {
|
|
802
371
|
vi.clearAllMocks();
|
|
803
|
-
mockExistsSync.mockReturnValue(true);
|
|
804
372
|
mockReadFile.mockResolvedValue('content');
|
|
805
373
|
});
|
|
806
374
|
```
|
|
807
375
|
|
|
808
|
-
**
|
|
376
|
+
**Critical anti-patterns**:
|
|
809
377
|
```typescript
|
|
810
|
-
// ❌
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
};
|
|
814
|
-
// This causes TypeScript errors and test failures!
|
|
815
|
-
```
|
|
816
|
-
|
|
817
|
-
**Why This Matters**:
|
|
818
|
-
1. `vi.mocked()` provides full type safety
|
|
819
|
-
2. Catches mock setup errors at compile time
|
|
820
|
-
3. Works correctly with Vitest's mock system
|
|
821
|
-
4. Prevents runtime "Cannot read properties of undefined" errors
|
|
822
|
-
|
|
823
|
-
**Common Mock Gotchas**:
|
|
824
|
-
- Always call `vi.clearAllMocks()` in beforeEach
|
|
825
|
-
- Use `mockResolvedValue` for async functions
|
|
826
|
-
- Use `mockReturnValue` for sync functions
|
|
827
|
-
- Check that mocks are actually called: `expect(mockFn).toHaveBeenCalled()`
|
|
378
|
+
// ❌ NEVER use jest APIs
|
|
379
|
+
jest.fn() // Use: vi.fn()
|
|
380
|
+
jest.mock() // Use: vi.mock()
|
|
828
381
|
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
**Lessons from fixing 72+ test failures (2025-11-17 Vitest migration)**
|
|
832
|
-
|
|
833
|
-
#### Critical Rules (Will Fail Tests)
|
|
382
|
+
// ❌ NEVER use project root in tests
|
|
383
|
+
const testRoot = path.join(process.cwd(), '.test-something');
|
|
834
384
|
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
require('../src/module') import { Module } from '../src/module.js'
|
|
838
|
-
jest.fn() vi.fn()
|
|
839
|
-
jest.mock() vi.mock()
|
|
840
|
-
fs as anyed<typeof fs> vi.mocked(fs.readFile)
|
|
841
|
-
const mock = vi.fn() vi.mock('mod', () => ({
|
|
842
|
-
vi.mock('mod', () => ({ mock })) method: vi.fn() // inline!
|
|
843
|
-
}))
|
|
844
|
-
mockReadJson.mockResolvedValue(arr) mockReadJson.mockResolvedValue([...arr]) // copy!
|
|
385
|
+
// ✅ ALWAYS use temp directory
|
|
386
|
+
const testRoot = path.join(os.tmpdir(), 'test-' + Date.now());
|
|
845
387
|
```
|
|
846
388
|
|
|
847
|
-
|
|
848
|
-
|
|
389
|
+
**Use test utilities**:
|
|
849
390
|
```typescript
|
|
850
|
-
import {
|
|
851
|
-
vi.mock('fs-extra', () => ({ default: { readFile: vi.fn() } }));
|
|
852
|
-
import fs from 'fs-extra';
|
|
853
|
-
|
|
854
|
-
describe('Feature', () => {
|
|
855
|
-
const mockReadFile = vi.mocked(fs.readFile);
|
|
856
|
-
|
|
857
|
-
beforeEach(() => {
|
|
858
|
-
vi.clearAllMocks();
|
|
859
|
-
mockReadFile.mockResolvedValue('data');
|
|
860
|
-
});
|
|
391
|
+
import { createIsolatedTestDir } from '../test-utils/isolated-test-dir';
|
|
861
392
|
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
393
|
+
const { testDir, cleanup } = await createIsolatedTestDir('my-test');
|
|
394
|
+
try {
|
|
395
|
+
// Test code here
|
|
396
|
+
} finally {
|
|
397
|
+
await cleanup(); // ALWAYS cleanup
|
|
398
|
+
}
|
|
867
399
|
```
|
|
868
400
|
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
- [ ] ES6 imports (NOT require())
|
|
872
|
-
- [ ] vi.* APIs (NOT jest.*)
|
|
873
|
-
- [ ] vi.mocked() for mocks (NOT anyed<>)
|
|
874
|
-
- [ ] Inline mock factories (NO external variables)
|
|
875
|
-
- [ ] Array copies in mocks (NO shared references)
|
|
876
|
-
- [ ] vi.clearAllMocks() in beforeEach()
|
|
877
|
-
|
|
878
|
-
**Full guide**: `tests/test-template.test.ts`
|
|
401
|
+
### Build Architecture
|
|
879
402
|
|
|
880
|
-
**
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
3. If `testRoot` points to project root → **DELETES REAL .specweave/!**
|
|
884
|
-
4. You lose all increments, docs, and history
|
|
403
|
+
**Dual compilation**:
|
|
404
|
+
- `tsc`: `src/` → `dist/src/` (source files)
|
|
405
|
+
- `esbuild`: `plugins/**/lib/hooks/*.ts` → in-place `.js` (hooks only)
|
|
885
406
|
|
|
886
|
-
**
|
|
407
|
+
**Hook imports**:
|
|
887
408
|
```typescript
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
test('my test', async () => {
|
|
891
|
-
const { testDir, cleanup } = await createIsolatedTestDir('my-test');
|
|
892
|
-
|
|
893
|
-
try {
|
|
894
|
-
// Setup .specweave structure in isolated directory
|
|
895
|
-
await createSpecweaveStructure(testDir);
|
|
896
|
-
|
|
897
|
-
// Test code here - NEVER touches project .specweave/
|
|
898
|
-
const incrementPath = path.join(testDir, '.specweave', 'increments', '0001-test');
|
|
899
|
-
// ...
|
|
900
|
-
} finally {
|
|
901
|
-
await cleanup(); // ALWAYS cleanup
|
|
902
|
-
}
|
|
903
|
-
});
|
|
904
|
-
```
|
|
905
|
-
|
|
906
|
-
**Protection Layers**:
|
|
907
|
-
1. ✅ **Pre-commit hook**: Blocks commits with dangerous test patterns
|
|
908
|
-
2. ✅ **Test utilities**: `tests/test-utils/isolated-test-dir.ts`
|
|
909
|
-
3. ✅ **Documentation**: This section
|
|
910
|
-
|
|
911
|
-
**Related Incident**: 2025-11-17 - Multiple `.specweave/` deletions traced to dangerous test patterns
|
|
912
|
-
**Root Cause Analysis**: `.specweave/increments/0037/reports/DELETION-ROOT-CAUSE-2025-11-17.md`
|
|
913
|
-
|
|
914
|
-
### Build Health Checks
|
|
915
|
-
|
|
916
|
-
**CRITICAL**: TypeScript ES Modules require specific practices:
|
|
917
|
-
|
|
918
|
-
1. **Always Import with .js Extensions**:
|
|
919
|
-
```typescript
|
|
920
|
-
// ❌ WRONG (will break at runtime):
|
|
921
|
-
import { foo } from './bar';
|
|
922
|
-
|
|
923
|
-
// ✅ CORRECT:
|
|
924
|
-
import { foo } from './bar.js';
|
|
925
|
-
```
|
|
926
|
-
|
|
927
|
-
2. **Fix Missing Extensions**:
|
|
928
|
-
```bash
|
|
929
|
-
# Auto-fix all missing .js extensions:
|
|
930
|
-
node scripts/fix-js-extensions.js
|
|
931
|
-
|
|
932
|
-
# Preview changes first:
|
|
933
|
-
node scripts/fix-js-extensions.js --dry-run
|
|
934
|
-
```
|
|
935
|
-
|
|
936
|
-
3. **Verify Build is Clean**:
|
|
937
|
-
```bash
|
|
938
|
-
# Check for polluted dist/ (TS5055 indicator):
|
|
939
|
-
find dist/src -name "*.ts" -not -name "*.d.ts"
|
|
940
|
-
# Should return NOTHING
|
|
941
|
-
|
|
942
|
-
# If files found, clean rebuild:
|
|
943
|
-
npm run rebuild
|
|
944
|
-
```
|
|
945
|
-
|
|
946
|
-
4. **Test Hook Execution**:
|
|
947
|
-
```bash
|
|
948
|
-
# Hooks must import correctly at runtime:
|
|
949
|
-
node plugins/specweave/lib/hooks/update-ac-status.js 0001
|
|
950
|
-
# Should execute without "Cannot find module" errors
|
|
951
|
-
```
|
|
952
|
-
|
|
953
|
-
5. **Install Git Hooks** (RECOMMENDED):
|
|
954
|
-
```bash
|
|
955
|
-
bash scripts/install-git-hooks.sh
|
|
956
|
-
# Verifies build health before every commit
|
|
957
|
-
```
|
|
958
|
-
|
|
959
|
-
### Common Build Errors & Fixes
|
|
960
|
-
|
|
961
|
-
**Error: TS5055 - Cannot write file (would overwrite input)**
|
|
962
|
-
```bash
|
|
963
|
-
# Cause: dist/ polluted with .ts source files
|
|
964
|
-
# Fix:
|
|
965
|
-
npm run clean && npm run build
|
|
966
|
-
```
|
|
967
|
-
|
|
968
|
-
**Error: Cannot find module 'src/...' (hook execution)**
|
|
969
|
-
```bash
|
|
970
|
-
# Cause: Hooks importing from src/ instead of dist/src/
|
|
971
|
-
# OR: Missing .js extensions in imports
|
|
972
|
-
# Fix:
|
|
973
|
-
node scripts/fix-js-extensions.js
|
|
974
|
-
npm run rebuild
|
|
975
|
-
```
|
|
976
|
-
|
|
977
|
-
**Error: Module import without .js extension**
|
|
978
|
-
```bash
|
|
979
|
-
# Cause: TypeScript ES modules REQUIRE .js in relative imports
|
|
980
|
-
# Fix:
|
|
981
|
-
node scripts/fix-js-extensions.js
|
|
409
|
+
#!/usr/bin/env node
|
|
410
|
+
import { ACStatusManager } from '../../../../dist/src/core/...'; // Use dist/
|
|
982
411
|
```
|
|
983
412
|
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
SpecWeave uses **dual compilation**:
|
|
987
|
-
- `tsc`: Compiles `src/` → `dist/src/` (source files)
|
|
988
|
-
- `esbuild`: Compiles `plugins/**/lib/hooks/*.ts` → in-place `.js` (hooks only)
|
|
989
|
-
|
|
990
|
-
**Why?** Hooks must import from `dist/src/` (compiled), but TypeScript would try to compile them before `dist/` exists (chicken-and-egg). Solution: Exclude hooks from `tsconfig.json`, compile separately with esbuild.
|
|
991
|
-
|
|
992
|
-
### Increment Scripts vs Hooks
|
|
993
|
-
|
|
994
|
-
**CRITICAL DISTINCTION**: Increment scripts and hooks have different purposes and import patterns.
|
|
995
|
-
|
|
996
|
-
**Hooks** (`plugins/**/lib/hooks/*.ts`):
|
|
997
|
-
- **Purpose**: Production runtime executables (called by shell scripts)
|
|
998
|
-
- **Execution**: `#!/usr/bin/env node` (JavaScript runtime)
|
|
999
|
-
- **Imports**: MUST use `dist/src/` (compiled JavaScript)
|
|
1000
|
-
- **Compilation**: esbuild (separate from main build)
|
|
1001
|
-
- **Example**:
|
|
1002
|
-
```typescript
|
|
1003
|
-
#!/usr/bin/env node
|
|
1004
|
-
import { ACStatusManager } from '../../../../dist/src/core/increment/ac-status-manager.js';
|
|
1005
|
-
```
|
|
1006
|
-
|
|
1007
|
-
**Increment Scripts** (`.specweave/increments/####/scripts/*.ts`):
|
|
1008
|
-
- **Purpose**: Development utilities (one-off tasks, migrations, analysis)
|
|
1009
|
-
- **Execution**: `#!/usr/bin/env tsx` (TypeScript runtime with ESM support)
|
|
1010
|
-
- **Imports**: MUST use `src/` (TypeScript source, NOT compiled)
|
|
1011
|
-
- **Compilation**: None (tsx transpiles on-the-fly)
|
|
1012
|
-
- **Example**:
|
|
1013
|
-
```typescript
|
|
1014
|
-
#!/usr/bin/env tsx
|
|
1015
|
-
import { ACStatusManager } from '../../../../src/core/increment/ac-status-manager.js';
|
|
1016
|
-
```
|
|
1017
|
-
|
|
1018
|
-
**Why Different Patterns?**
|
|
1019
|
-
|
|
1020
|
-
| Aspect | Hooks (dist/) | Increment Scripts (src/) |
|
|
1021
|
-
|--------|---------------|-------------------------|
|
|
1022
|
-
| **Context** | Production runtime | Development only |
|
|
1023
|
-
| **Tooling** | Node.js only | TypeScript tooling (tsx) |
|
|
1024
|
-
| **Build dependency** | Yes (requires dist/) | No (live source code) |
|
|
1025
|
-
| **Live reload** | No (must rebuild) | Yes (tsx auto-transpiles) |
|
|
1026
|
-
| **Purpose** | Permanent infrastructure | Temporary dev utilities |
|
|
1027
|
-
|
|
1028
|
-
**Common Mistake**: Copying hook import patterns to increment scripts.
|
|
1029
|
-
|
|
413
|
+
**Increment script imports**:
|
|
1030
414
|
```typescript
|
|
1031
|
-
// ❌ WRONG (increment script importing from dist/):
|
|
1032
|
-
#!/usr/bin/env tsx
|
|
1033
|
-
import { ACStatusManager } from '../../../../dist/src/core/...';
|
|
1034
|
-
// Issues:
|
|
1035
|
-
// - Requires npm run build before execution
|
|
1036
|
-
// - Stale code if src/ changes without rebuild
|
|
1037
|
-
// - Semantic confusion (TS runtime + JS imports)
|
|
1038
|
-
|
|
1039
|
-
// ✅ CORRECT (increment script importing from src/):
|
|
1040
415
|
#!/usr/bin/env tsx
|
|
1041
|
-
import { ACStatusManager } from '../../../../src/core/...';
|
|
1042
|
-
// Benefits:
|
|
1043
|
-
// - No build dependency
|
|
1044
|
-
// - Always uses latest source code
|
|
1045
|
-
// - Clear dev script pattern
|
|
416
|
+
import { ACStatusManager } from '../../../../src/core/...'; // Use src/
|
|
1046
417
|
```
|
|
1047
418
|
|
|
1048
|
-
**
|
|
1049
|
-
|
|
1050
|
-
### Running Increment Scripts
|
|
1051
|
-
|
|
1052
|
-
**CRITICAL**: Increment scripts use `#!/usr/bin/env tsx` shebang, which assumes tsx is in your PATH. This often fails in development environments.
|
|
1053
|
-
|
|
1054
|
-
**Recommended Execution Method** (Always Works):
|
|
419
|
+
**Running increment scripts**:
|
|
1055
420
|
```bash
|
|
1056
|
-
# ✅ Use npx - finds tsx in node_modules/.bin/ automatically
|
|
1057
421
|
npx tsx .specweave/increments/####/scripts/script-name.ts
|
|
1058
|
-
|
|
1059
|
-
# Example:
|
|
1060
|
-
npx tsx .specweave/increments/0037-project-specific-tasks/scripts/validate-task-consistency.ts
|
|
1061
|
-
```
|
|
1062
|
-
|
|
1063
|
-
**Why npx?**
|
|
1064
|
-
- ✅ Works without global tsx installation
|
|
1065
|
-
- ✅ Uses project's tsx version (consistent across team)
|
|
1066
|
-
- ✅ No PATH configuration needed
|
|
1067
|
-
- ✅ Same behavior in CI/CD and local dev
|
|
1068
|
-
|
|
1069
|
-
**Alternative Methods** (Less Recommended):
|
|
1070
|
-
```bash
|
|
1071
|
-
# Option 1: Direct execution (requires global tsx)
|
|
1072
|
-
chmod +x script.ts
|
|
1073
|
-
./script.ts
|
|
1074
|
-
# ❌ Fails if tsx not globally installed
|
|
1075
|
-
|
|
1076
|
-
# Option 2: Install tsx globally (not recommended for teams)
|
|
1077
|
-
npm install -g tsx
|
|
1078
|
-
./script.ts
|
|
1079
|
-
# ❌ Every contributor must install globally
|
|
1080
|
-
# ❌ Version inconsistencies across team
|
|
1081
|
-
|
|
1082
|
-
# Option 3: Full path
|
|
1083
|
-
./node_modules/.bin/tsx script.ts
|
|
1084
|
-
# ✅ Works, but verbose
|
|
1085
|
-
```
|
|
1086
|
-
|
|
1087
|
-
**Troubleshooting "command not found: tsx" (Exit Code 127)**:
|
|
1088
|
-
|
|
1089
|
-
This error means tsx isn't in your shell's PATH.
|
|
1090
|
-
|
|
1091
|
-
**Root Cause**:
|
|
1092
|
-
- tsx is a **dev dependency** (installed in `node_modules/`)
|
|
1093
|
-
- Shell can't find commands in `node_modules/.bin/` automatically
|
|
1094
|
-
- npm scripts add `node_modules/.bin/` to PATH, but direct shell execution doesn't
|
|
1095
|
-
|
|
1096
|
-
**Fix**:
|
|
1097
|
-
```bash
|
|
1098
|
-
# Instead of:
|
|
1099
|
-
tsx script.ts # ❌ Fails with error 127
|
|
1100
|
-
|
|
1101
|
-
# Use:
|
|
1102
|
-
npx tsx script.ts # ✅ Always works
|
|
1103
422
|
```
|
|
1104
423
|
|
|
1105
|
-
|
|
1106
|
-
- **npm scripts**: Work (PATH includes node_modules/.bin/)
|
|
1107
|
-
- **Direct shell**: Fails (PATH doesn't include node_modules/.bin/)
|
|
1108
|
-
- **Global tsx installed**: Works (tsx in system PATH)
|
|
1109
|
-
- **CI/CD**: Depends on environment setup
|
|
1110
|
-
|
|
1111
|
-
**Execution Context Comparison**:
|
|
1112
|
-
|
|
1113
|
-
| Method | tsx in PATH? | Works? |
|
|
1114
|
-
|--------|--------------|--------|
|
|
1115
|
-
| `npm run script` | ✅ Yes (npm adds it) | ✅ Yes |
|
|
1116
|
-
| `./script.ts` | ❌ No (unless global) | ❌ Usually fails |
|
|
1117
|
-
| `tsx script.ts` | ❌ No (unless global) | ❌ Usually fails |
|
|
1118
|
-
| `npx tsx script.ts` | ✅ Yes (npx finds it) | ✅ Always works |
|
|
1119
|
-
|
|
1120
|
-
**Best Practice for Contributors**:
|
|
1121
|
-
- **Creating scripts**: Use `#!/usr/bin/env tsx` shebang (conventional)
|
|
1122
|
-
- **Running scripts**: Always use `npx tsx script.ts` (reliable)
|
|
1123
|
-
- **Documentation**: Show npx execution method in examples
|
|
1124
|
-
|
|
1125
|
-
### Coverage Requirements
|
|
424
|
+
### Coverage
|
|
1126
425
|
|
|
1127
426
|
- Critical paths: 90%+
|
|
1128
427
|
- Overall: 80%+
|
|
1129
428
|
|
|
1130
|
-
### Related Documentation
|
|
1131
|
-
|
|
1132
|
-
- Build process details: `.github/CONTRIBUTING.md` → "Build Process & Best Practices"
|
|
1133
|
-
- Ultrathink analysis: `.specweave/increments/0039/reports/HOOK-IMPORT-ERROR-ULTRATHINK-ANALYSIS.md`
|
|
1134
|
-
- Build verification tests: `tests/integration/build/build-verification.test.ts`
|
|
1135
|
-
|
|
1136
429
|
---
|
|
1137
430
|
|
|
1138
431
|
## Common Tasks
|
|
1139
432
|
|
|
1140
|
-
### Adding
|
|
433
|
+
### Adding Components
|
|
1141
434
|
|
|
1142
|
-
|
|
1143
|
-
-
|
|
1144
|
-
-
|
|
1145
|
-
-
|
|
435
|
+
All components go into `plugins/`:
|
|
436
|
+
- Core: `plugins/specweave/{skills|agents|commands|hooks}/`
|
|
437
|
+
- Plugins: `plugins/specweave-{name}/{skills|agents|commands}/`
|
|
438
|
+
- Tests: `tests/integration/` or `tests/unit/`
|
|
1146
439
|
|
|
1147
|
-
|
|
440
|
+
See `.github/CONTRIBUTING.md` for details.
|
|
1148
441
|
|
|
1149
442
|
### Updating Documentation
|
|
1150
443
|
|
|
1151
444
|
```bash
|
|
1152
|
-
# Internal docs
|
|
445
|
+
# Internal docs
|
|
1153
446
|
vim .specweave/docs/internal/architecture/hld-system.md
|
|
1154
447
|
|
|
1155
|
-
# Public docs
|
|
448
|
+
# Public docs
|
|
1156
449
|
vim .specweave/docs/public/guides/user-guide.md
|
|
1157
|
-
|
|
1158
|
-
# Build docs site
|
|
1159
|
-
cd docs-site && npm run build
|
|
1160
450
|
```
|
|
1161
451
|
|
|
1162
452
|
---
|
|
1163
453
|
|
|
1164
454
|
## Troubleshooting
|
|
1165
455
|
|
|
1166
|
-
**Skills not activating
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
**Commands not working?**
|
|
1173
|
-
1. Check plugin installed: `/plugin list --installed`
|
|
1174
|
-
2. Verify command exists in plugin
|
|
1175
|
-
3. Restart Claude Code
|
|
1176
|
-
|
|
1177
|
-
**Tests failing?**
|
|
1178
|
-
1. Run `npm run build` first
|
|
1179
|
-
2. Check test output
|
|
1180
|
-
3. Verify test data in `tests/fixtures/`
|
|
1181
|
-
|
|
1182
|
-
**Root folder polluted?**
|
|
1183
|
-
1. Move files to `.specweave/increments/####/reports/`
|
|
1184
|
-
2. Update `.gitignore` if needed
|
|
1185
|
-
|
|
1186
|
-
**Plugin hooks not working? (Development)**
|
|
1187
|
-
See `.claude/CONTRIBUTING.md` for plugin marketplace setup.
|
|
1188
|
-
|
|
1189
|
-
---
|
|
1190
|
-
|
|
1191
|
-
## Getting Help
|
|
1192
|
-
|
|
1193
|
-
**Documentation**:
|
|
1194
|
-
- User docs: https://spec-weave.com
|
|
1195
|
-
- Contributor docs: `.specweave/docs/internal/`
|
|
1196
|
-
- Architecture: `.specweave/docs/internal/architecture/`
|
|
1197
|
-
|
|
1198
|
-
**Community**:
|
|
1199
|
-
- GitHub Issues: https://github.com/anton-abyzov/specweave/issues
|
|
1200
|
-
- Discussions: https://github.com/anton-abyzov/specweave/discussions
|
|
1201
|
-
|
|
1202
|
-
**Current Increment**:
|
|
1203
|
-
```bash
|
|
1204
|
-
/specweave:status # Show all increments
|
|
1205
|
-
```
|
|
456
|
+
**Skills not activating**: Check YAML frontmatter, restart Claude Code
|
|
457
|
+
**Commands not working**: Verify plugin installed, restart Claude Code
|
|
458
|
+
**Tests failing**: Run `npm run rebuild`, check test output
|
|
459
|
+
**Root folder polluted**: Move files to `.specweave/increments/####/reports/`
|
|
460
|
+
**Hooks failing**: Verify symlink (see "Symlink Setup" above)
|
|
1206
461
|
|
|
1207
462
|
---
|
|
1208
463
|
|
|
1209
464
|
## Quick Reference
|
|
1210
465
|
|
|
1211
|
-
**Commands
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
- `/specweave:
|
|
1215
|
-
- `/specweave:do` - Execute tasks
|
|
1216
|
-
- `/specweave:done 0002` - Close increment
|
|
1217
|
-
- `/specweave:validate 0002` - Validate increment
|
|
1218
|
-
- `/specweave:qa 0002` - Quality assessment
|
|
466
|
+
**Commands**:
|
|
467
|
+
- `/specweave:increment "feature"` - Plan
|
|
468
|
+
- `/specweave:do` - Execute
|
|
469
|
+
- `/specweave:done 0002` - Close (validates)
|
|
1219
470
|
- `/specweave:status` - Show status
|
|
1220
471
|
- `/specweave:progress` - Check progress
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
- `/specweave:pause
|
|
1224
|
-
- `/specweave:
|
|
1225
|
-
- `/specweave:abandon 0002 --reason="..."` - Abandon
|
|
1226
|
-
|
|
1227
|
-
*Archiving (MANUAL ONLY)*:
|
|
1228
|
-
- `/specweave:archive 0031` - Archive specific
|
|
1229
|
-
- `/specweave:archive --keep-last 10` - Archive old
|
|
1230
|
-
- `/specweave:restore 0031` - Restore
|
|
1231
|
-
- `/specweave:fix-duplicates` - Resolve duplicates
|
|
1232
|
-
|
|
1233
|
-
*Documentation*:
|
|
472
|
+
- `/specweave:validate 0002` - Validate
|
|
473
|
+
- `/specweave:qa 0002` - Quality check
|
|
474
|
+
- `/specweave:pause/resume/abandon` - State management
|
|
475
|
+
- `/specweave:archive/restore` - Archiving (manual only)
|
|
1234
476
|
- `/specweave:sync-docs update` - Sync living docs
|
|
1235
|
-
- `/specweave:sync-tasks` - Sync task status
|
|
1236
477
|
|
|
1237
|
-
|
|
1238
|
-
-
|
|
1239
|
-
-
|
|
1240
|
-
-
|
|
1241
|
-
-
|
|
1242
|
-
|
|
1243
|
-
**Build & Test**:
|
|
1244
|
-
- `npm run build` - Compile TypeScript
|
|
1245
|
-
- `npm test` - Unit tests
|
|
1246
|
-
- `npm run test:e2e` - E2E tests
|
|
1247
|
-
- `npm run test:integration` - Integration tests
|
|
478
|
+
**Build**:
|
|
479
|
+
- `npm run rebuild` - Clean + build
|
|
480
|
+
- `npm test` - Smoke tests
|
|
481
|
+
- `npm run test:all` - All tests
|
|
482
|
+
- `npm run test:coverage` - Coverage
|
|
1248
483
|
|
|
1249
484
|
**File Structure**:
|
|
1250
|
-
- Source: `src/` (TypeScript)
|
|
1251
|
-
- Marketplace: GLOBAL (via CLI)
|
|
485
|
+
- Source: `src/` (TypeScript), `plugins/` (skills/agents/commands/hooks)
|
|
1252
486
|
- Increments: `.specweave/increments/`
|
|
1253
|
-
- Docs: `.specweave/docs/internal
|
|
487
|
+
- Docs: `.specweave/docs/internal/`, `.specweave/docs/public/`
|
|
1254
488
|
- Tests: `tests/` (unit, integration, E2E)
|
|
1255
489
|
|
|
1256
|
-
---
|
|
1257
|
-
|
|
1258
490
|
**Remember**:
|
|
1259
|
-
1.
|
|
1260
|
-
2. Keep root
|
|
1261
|
-
3. Test before committing
|
|
1262
|
-
4.
|
|
1263
|
-
5.
|
|
1264
|
-
|
|
1265
|
-
**
|
|
1266
|
-
**Last Updated**: 2025-11-15
|
|
491
|
+
1. Symlink setup is MANDATORY for contributors
|
|
492
|
+
2. Keep root clean (use increment folders)
|
|
493
|
+
3. Test before committing
|
|
494
|
+
4. Never delete .specweave/ directories
|
|
495
|
+
5. Use `/specweave:done` (never manual metadata edits)
|
|
496
|
+
|
|
497
|
+
**See also**: `.github/CONTRIBUTING.md`, https://spec-weave.com
|