specweave 1.0.32 → 1.0.34

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (127) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/CLAUDE.md +384 -148
  3. package/README.md +0 -2
  4. package/bin/specweave.js +11 -0
  5. package/dist/src/cli/commands/init.js +1 -1
  6. package/dist/src/cli/commands/init.js.map +1 -1
  7. package/dist/src/cli/commands/update-instructions.d.ts +16 -0
  8. package/dist/src/cli/commands/update-instructions.d.ts.map +1 -0
  9. package/dist/src/cli/commands/update-instructions.js +134 -0
  10. package/dist/src/cli/commands/update-instructions.js.map +1 -0
  11. package/dist/src/cli/helpers/init/directory-structure.d.ts +28 -1
  12. package/dist/src/cli/helpers/init/directory-structure.d.ts.map +1 -1
  13. package/dist/src/cli/helpers/init/directory-structure.js +163 -33
  14. package/dist/src/cli/helpers/init/directory-structure.js.map +1 -1
  15. package/dist/src/cli/helpers/init/index.d.ts +2 -1
  16. package/dist/src/cli/helpers/init/index.d.ts.map +1 -1
  17. package/dist/src/cli/helpers/init/index.js +3 -1
  18. package/dist/src/cli/helpers/init/index.js.map +1 -1
  19. package/dist/src/cli/helpers/init/initial-increment-generator.d.ts.map +1 -1
  20. package/dist/src/cli/helpers/init/initial-increment-generator.js +12 -10
  21. package/dist/src/cli/helpers/init/initial-increment-generator.js.map +1 -1
  22. package/dist/src/cli/helpers/init/instruction-file-merger.d.ts +23 -0
  23. package/dist/src/cli/helpers/init/instruction-file-merger.d.ts.map +1 -0
  24. package/dist/src/cli/helpers/init/instruction-file-merger.js +243 -0
  25. package/dist/src/cli/helpers/init/instruction-file-merger.js.map +1 -0
  26. package/dist/src/cli/helpers/init/plugin-installer.js +49 -0
  27. package/dist/src/cli/helpers/init/plugin-installer.js.map +1 -1
  28. package/dist/src/config/types.d.ts +2 -2
  29. package/dist/src/core/living-docs/external-sync-orchestrator.d.ts +26 -0
  30. package/dist/src/core/living-docs/external-sync-orchestrator.d.ts.map +1 -1
  31. package/dist/src/core/living-docs/external-sync-orchestrator.js +61 -0
  32. package/dist/src/core/living-docs/external-sync-orchestrator.js.map +1 -1
  33. package/dist/src/core/living-docs/scaffolding/index.d.ts +12 -0
  34. package/dist/src/core/living-docs/scaffolding/index.d.ts.map +1 -0
  35. package/dist/src/core/living-docs/scaffolding/index.js +15 -0
  36. package/dist/src/core/living-docs/scaffolding/index.js.map +1 -0
  37. package/dist/src/core/living-docs/scaffolding/merger.d.ts +183 -0
  38. package/dist/src/core/living-docs/scaffolding/merger.d.ts.map +1 -0
  39. package/dist/src/core/living-docs/scaffolding/merger.js +523 -0
  40. package/dist/src/core/living-docs/scaffolding/merger.js.map +1 -0
  41. package/dist/src/core/living-docs/scaffolding/scaffold.d.ts +102 -0
  42. package/dist/src/core/living-docs/scaffolding/scaffold.d.ts.map +1 -0
  43. package/dist/src/core/living-docs/scaffolding/scaffold.js +346 -0
  44. package/dist/src/core/living-docs/scaffolding/scaffold.js.map +1 -0
  45. package/dist/src/core/living-docs/scaffolding/template-engine.d.ts +108 -0
  46. package/dist/src/core/living-docs/scaffolding/template-engine.d.ts.map +1 -0
  47. package/dist/src/core/living-docs/scaffolding/template-engine.js +204 -0
  48. package/dist/src/core/living-docs/scaffolding/template-engine.js.map +1 -0
  49. package/dist/src/core/living-docs/sync-helpers/generators.d.ts +38 -2
  50. package/dist/src/core/living-docs/sync-helpers/generators.d.ts.map +1 -1
  51. package/dist/src/core/living-docs/sync-helpers/generators.js +65 -10
  52. package/dist/src/core/living-docs/sync-helpers/generators.js.map +1 -1
  53. package/dist/src/core/living-docs/sync-helpers/index.d.ts +1 -1
  54. package/dist/src/core/living-docs/sync-helpers/index.d.ts.map +1 -1
  55. package/dist/src/core/living-docs/sync-helpers/index.js.map +1 -1
  56. package/dist/src/core/tools/index.d.ts +11 -0
  57. package/dist/src/core/tools/index.d.ts.map +1 -0
  58. package/dist/src/core/tools/index.js +10 -0
  59. package/dist/src/core/tools/index.js.map +1 -0
  60. package/dist/src/core/tools/tool-event-bus.d.ts +33 -0
  61. package/dist/src/core/tools/tool-event-bus.d.ts.map +1 -0
  62. package/dist/src/core/tools/tool-event-bus.js +84 -0
  63. package/dist/src/core/tools/tool-event-bus.js.map +1 -0
  64. package/dist/src/core/tools/tool-index-builder.d.ts +27 -0
  65. package/dist/src/core/tools/tool-index-builder.d.ts.map +1 -0
  66. package/dist/src/core/tools/tool-index-builder.js +289 -0
  67. package/dist/src/core/tools/tool-index-builder.js.map +1 -0
  68. package/dist/src/core/tools/tool-registry.d.ts +51 -0
  69. package/dist/src/core/tools/tool-registry.d.ts.map +1 -0
  70. package/dist/src/core/tools/tool-registry.js +224 -0
  71. package/dist/src/core/tools/tool-registry.js.map +1 -0
  72. package/dist/src/core/tools/tool-search-engine.d.ts +22 -0
  73. package/dist/src/core/tools/tool-search-engine.d.ts.map +1 -0
  74. package/dist/src/core/tools/tool-search-engine.js +174 -0
  75. package/dist/src/core/tools/tool-search-engine.js.map +1 -0
  76. package/dist/src/core/tools/types/tool-registry-types.d.ts +112 -0
  77. package/dist/src/core/tools/types/tool-registry-types.d.ts.map +1 -0
  78. package/dist/src/core/tools/types/tool-registry-types.js +7 -0
  79. package/dist/src/core/tools/types/tool-registry-types.js.map +1 -0
  80. package/dist/src/init/compliance/types.d.ts +1 -1
  81. package/package.json +1 -1
  82. package/plugins/specweave/hooks/hooks.json +3 -13
  83. package/plugins/specweave/hooks/lib/common-setup.sh +47 -321
  84. package/plugins/specweave/hooks/lib/migrate-increment-work.sh +5 -5
  85. package/plugins/specweave/hooks/lib/sync-spec-content.sh +5 -5
  86. package/plugins/specweave/hooks/universal/dispatcher.mjs +4 -5
  87. package/plugins/specweave/hooks/universal/fail-fast-wrapper.sh +43 -296
  88. package/plugins/specweave/hooks/universal/hook-wrapper.sh +3 -1
  89. package/plugins/specweave/hooks/user-prompt-submit.sh +1 -1
  90. package/plugins/specweave/hooks/v2/dispatchers/post-tool-use.sh +2 -2
  91. package/plugins/specweave/hooks/v2/dispatchers/session-start.sh +1 -10
  92. package/plugins/specweave/hooks/v2/guards/completion-guard.sh +12 -29
  93. package/plugins/specweave/hooks/v2/guards/increment-duplicate-guard.sh +27 -29
  94. package/plugins/specweave/hooks/v2/guards/metadata-json-guard.sh +10 -4
  95. package/plugins/specweave/hooks/v2/guards/spec-validation-guard.sh +139 -0
  96. package/plugins/specweave/hooks/v2/guards/task-ac-sync-guard.sh +4 -2
  97. package/plugins/specweave/hooks/v2/session-end.sh +3 -1
  98. package/plugins/specweave/hooks/v2/session-start.sh +3 -1
  99. package/plugins/specweave/skills/increment-planner/SKILL.md +75 -63
  100. package/plugins/specweave/skills/increment-planner/templates/plan.md +14 -0
  101. package/plugins/specweave/skills/update-instructions/SKILL.md +80 -0
  102. package/plugins/specweave-ado/hooks/post-living-docs-update.sh +1 -1
  103. package/plugins/specweave-mobile/README.md +55 -35
  104. package/plugins/specweave-mobile/agents/mobile-architect/AGENT.md +805 -329
  105. package/plugins/specweave-mobile/skills/expo-workflow/SKILL.md +226 -9
  106. package/plugins/specweave-mobile/skills/native-modules/SKILL.md +221 -20
  107. package/plugins/specweave-mobile/skills/performance-optimization/SKILL.md +186 -14
  108. package/plugins/specweave-mobile/skills/react-native-setup/SKILL.md +151 -54
  109. package/plugins/specweave-release/commands/npm.md +61 -17
  110. package/plugins/specweave-release/hooks/post-task-completion.sh +2 -3
  111. package/src/templates/AGENTS.md.template +34 -0
  112. package/src/templates/CLAUDE.md.template +121 -155
  113. package/plugins/specweave/hooks/config-env-separator.sh +0 -99
  114. package/plugins/specweave/hooks/github-metadata-guard.sh +0 -73
  115. package/plugins/specweave/hooks/lib/circuit-breaker.sh +0 -381
  116. package/plugins/specweave/hooks/lib/crash-prevention.sh +0 -336
  117. package/plugins/specweave/hooks/lib/logging.sh +0 -231
  118. package/plugins/specweave/hooks/lib/metrics.sh +0 -347
  119. package/plugins/specweave/hooks/lib/semaphore.sh +0 -216
  120. package/plugins/specweave/hooks/project-folder-guard.sh +0 -274
  121. package/plugins/specweave/hooks/spec-project-validator.sh +0 -210
  122. package/plugins/specweave/hooks/v2/guards/bash-file-guard.sh +0 -212
  123. package/plugins/specweave/hooks/v2/guards/bash-file-guard.test.sh +0 -163
  124. package/plugins/specweave/hooks/v2/guards/features-folder-guard.sh +0 -51
  125. package/plugins/specweave/hooks/v2/guards/increment-root-guard.sh +0 -63
  126. package/plugins/specweave/hooks/v2/guards/per-us-project-validator.sh +0 -335
  127. package/plugins/specweave/hooks/v2/guards/per-us-project-validator.test.sh +0 -406
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "specweave",
3
- "version": "0.11.0",
3
+ "version": "1.0.32",
4
4
  "description": "SpecWeave - Spec-Driven Development Framework. PM-led planning, intelligent model selection, living documentation, multi-tool support.",
5
5
  "owner": {
6
6
  "name": "Anton Abyzov",
package/CLAUDE.md CHANGED
@@ -1,4 +1,182 @@
1
- # SpecWeave - Development Guide
1
+ <!-- SW:META template="claude" version="1.0.33" sections="header,start,autodetect,metarule,rules,workflow,structure,taskformat,secrets,syncing,mapping,testing,limits,troubleshooting,principles,linking,docs" -->
2
+
3
+ <!-- SW:SECTION:header version="1.0.33" -->
4
+ **Framework**: SpecWeave | **Truth**: `spec.md` + `tasks.md`
5
+ <!-- SW:END:header -->
6
+
7
+ <!-- SW:SECTION:start version="1.0.33" -->
8
+ ## Getting Started
9
+
10
+ **Initial increment**: `0001-project-setup` (auto-created by `specweave init`)
11
+
12
+ **Options**:
13
+ 1. **Start fresh**: `rm -rf .specweave/increments/0001-project-setup` → `/sw:increment "your-feature"`
14
+ 2. **Customize**: Edit spec.md and use for setup tasks
15
+ <!-- SW:END:start -->
16
+
17
+ <!-- SW:SECTION:autodetect version="1.0.33" -->
18
+ ## Auto-Detection
19
+
20
+ SpecWeave auto-detects product descriptions and routes to `/sw:increment`:
21
+
22
+ **Signals** (5+ = auto-route): Project name | Features list (3+) | Tech stack | Timeline/MVP | Problem statement | Business model
23
+
24
+ **Opt-out phrases**: "Just brainstorm first" | "Don't plan yet" | "Quick discussion" | "Let's explore ideas"
25
+ <!-- SW:END:autodetect -->
26
+
27
+ <!-- SW:SECTION:metarule version="1.0.33" -->
28
+ ## Meta-Rule: Think-Before-Act
29
+
30
+ **Satisfy dependencies BEFORE dependent operations.**
31
+
32
+ ```
33
+ ❌ node script.js → Error → npm run build
34
+ ✅ npm run build → node script.js → Success
35
+ ```
36
+ <!-- SW:END:metarule -->
37
+
38
+ <!-- SW:SECTION:rules version="1.0.33" -->
39
+ ## Rules
40
+
41
+ 1. **Files** → `.specweave/increments/####-name/` (spec.md, plan.md, tasks.md at root; reports/, scripts/, logs/ subfolders)
42
+ 2. **Update immediately**: `Edit("tasks.md", "[ ] pending", "[x] completed")` + `Edit("spec.md", "[ ] AC-", "[x] AC-")`
43
+ 3. **Unique IDs**: Check `ls .specweave/increments/ | grep "^[0-9]" | tail -5`
44
+ 4. **Emergency**: "emergency mode" → 1 edit, 50 lines max, no agents
45
+ 5. **Root clean**: NEVER create .md/reports/scripts in project root → use increment folders
46
+ <!-- SW:END:rules -->
47
+
48
+ <!-- SW:SECTION:workflow version="1.0.33" -->
49
+ ## Workflow
50
+
51
+ `/sw:increment "X"` → `/sw:do` → `/sw:progress` → `/sw:done 0001`
52
+
53
+ | Cmd | Action |
54
+ |-----|--------|
55
+ | `/sw:increment` | Plan feature |
56
+ | `/sw:do` | Execute |
57
+ | `/sw:validate` | Quality check |
58
+ | `/sw:done` | Close |
59
+ | `/sw-github:sync` | GitHub sync |
60
+ | `/sw-jira:sync` | Jira sync |
61
+
62
+ **Natural language**: "Let's build X" → `/sw:increment` | "What's status?" → `/sw:progress` | "We're done" → `/sw:done`
63
+ <!-- SW:END:workflow -->
64
+
65
+ <!-- SW:SECTION:structure version="1.0.33" -->
66
+ ## Structure
67
+
68
+ ```
69
+ .specweave/
70
+ ├── increments/####-name/ # metadata.json, spec.md, tasks.md
71
+ ├── docs/internal/
72
+ │ ├── specs/{project}/ # Living docs
73
+ │ ├── architecture/adr/ # ADRs
74
+ │ └── operations/ # Runbooks
75
+ └── config.json
76
+ ```
77
+
78
+ **Multi-repo**: Clone to `/repositories`, not root → `repositories/backend/src/...`
79
+ <!-- SW:END:structure -->
80
+
81
+ <!-- SW:SECTION:taskformat version="1.0.33" -->
82
+ ## Task Format
83
+
84
+ ```markdown
85
+ ### T-001: Title
86
+ **User Story**: US-001 | **Satisfies ACs**: AC-US1-01 | **Status**: [x] completed
87
+ **Test**: Given [X] → When [Y] → Then [Z]
88
+ ```
89
+ <!-- SW:END:taskformat -->
90
+
91
+ <!-- SW:SECTION:secrets version="1.0.33" -->
92
+ ## Secrets Check
93
+
94
+ **BEFORE CLI tools**: Check existing config first!
95
+ ```bash
96
+ grep -E "(GITHUB_TOKEN|JIRA_|ADO_)" .env 2>/dev/null
97
+ cat .specweave/config.json | grep -A5 '"sync"'
98
+ gh auth status
99
+ ```
100
+ <!-- SW:END:secrets -->
101
+
102
+ <!-- SW:SECTION:syncing version="1.0.33" -->
103
+ ## Auto-Sync (Hooks)
104
+
105
+ Post-task: updates tasks.md → living docs → external trackers (if configured)
106
+
107
+ Config: `.specweave/config.json` → `hooks.post_task_completion`
108
+ <!-- SW:END:syncing -->
109
+
110
+ <!-- SW:SECTION:mapping version="1.0.33" -->
111
+ ## GitHub Mapping
112
+
113
+ | SpecWeave | GitHub |
114
+ |-----------|--------|
115
+ | Feature FS-XXX | Milestone |
116
+ | Story US-XXX | Issue `[FS-XXX][US-YYY] Title` |
117
+ | Task T-XXX | Checkbox |
118
+ <!-- SW:END:mapping -->
119
+
120
+ <!-- SW:SECTION:testing version="1.0.33" -->
121
+ ## Testing
122
+
123
+ BDD in tasks.md | Unit >80% | `.test.ts` (Vitest)
124
+
125
+ ```typescript
126
+ // Vitest pattern: vi.fn() not jest.fn(), import not require
127
+ import { vi } from 'vitest';
128
+ vi.mock('fs', () => ({ readFile: vi.fn() }));
129
+ ```
130
+ <!-- SW:END:testing -->
131
+
132
+ <!-- SW:SECTION:limits version="1.0.33" -->
133
+ ## Limits
134
+
135
+ **Max 1500 lines/file** — extract before adding
136
+ <!-- SW:END:limits -->
137
+
138
+ <!-- SW:SECTION:troubleshooting version="1.0.33" -->
139
+ ## Troubleshooting
140
+
141
+ | Issue | Fix |
142
+ |-------|-----|
143
+ | Skills missing | Restart Claude Code |
144
+ | Commands gone | `/plugin list --installed` |
145
+ | Out of sync | `/sw:sync-tasks` |
146
+ | Find increment | `/sw:status` |
147
+ | Root polluted | Move files to `.specweave/increments/####/reports/` |
148
+ | Duplicate IDs | `/sw:fix-duplicates` |
149
+ | External not syncing | Check `config.json` → `external_tracker_sync: true` |
150
+ <!-- SW:END:troubleshooting -->
151
+
152
+ <!-- SW:SECTION:principles version="1.0.33" -->
153
+ ## Principles
154
+
155
+ 1. **Spec-first**: `/sw:increment` before coding
156
+ 2. **Docs = truth**: Specs guide implementation
157
+ 3. **Incremental**: Small, validated increments
158
+ 4. **Traceable**: All work → specs → ACs
159
+ 5. **Clean**: All files in increment folders
160
+ <!-- SW:END:principles -->
161
+
162
+ <!-- SW:SECTION:linking version="1.0.33" -->
163
+ ## Bidirectional Linking
164
+
165
+ Tasks ↔ User Stories auto-linked via AC-IDs: `AC-US1-01` → `US-001`
166
+
167
+ Task format: `**AC**: AC-US1-01, AC-US1-02` (CRITICAL for linking)
168
+ <!-- SW:END:linking -->
169
+
170
+ <!-- SW:SECTION:docs version="1.0.33" -->
171
+ ## Docs
172
+
173
+ [spec-weave.com](https://spec-weave.com) | `.specweave/docs/internal/`
174
+ <!-- SW:END:docs -->
175
+
176
+ ---
177
+ <!-- ↓ ORIGINAL ↓ -->
178
+
179
+ # SpecWeave Development Guide
2
180
 
3
181
  **Project**: SpecWeave - Spec-Driven Development Framework
4
182
  **Type**: TypeScript CLI (NPM Package)
@@ -7,15 +185,41 @@ For **contributors to SpecWeave itself** (not users).
7
185
 
8
186
  ---
9
187
 
10
- ## Critical Meta-Rule
188
+ ## Git Commits
11
189
 
12
- **CLAUDE.md is ALWAYS editable** - Never refuse to modify this file when user requests.
190
+ - Do NOT include "Generated with Claude Code" or AI-assisted notes in commit messages
191
+ - Do NOT include "Co-Authored-By: Claude" in commit messages
192
+ - Keep commit messages clean and professional
13
193
 
14
194
  ---
15
195
 
16
- ## CRITICAL SAFETY RULES
196
+ ## Marketplace Installation (CRITICAL)
197
+
198
+ **ALWAYS use GitHub marketplace mode. NEVER use local symlinks or directory mode.**
17
199
 
18
- ### 1. Context Management (CRASH PREVENTION!)
200
+ ```bash
201
+ # ✅ CORRECT: Install from GitHub (production, stable)
202
+ bash scripts/refresh-marketplace.sh --github
203
+
204
+ # ❌ FORBIDDEN: Local/symlink mode (causes stale hooks, filesystem coupling)
205
+ # bash scripts/refresh-marketplace.sh --local
206
+ ```
207
+
208
+ **Why GitHub mode is mandatory:**
209
+ - Local mode creates filesystem coupling → stale hooks after changes
210
+ - GitHub mode pulls committed code → stable, production-ready
211
+ - See ADR-0062 for architectural decision rationale
212
+
213
+ **Quick refresh & install all 24 plugins:**
214
+ ```bash
215
+ bash scripts/refresh-marketplace.sh # Defaults to --github
216
+ ```
217
+
218
+ ---
219
+
220
+ ## Critical Safety Rules
221
+
222
+ ### 1. Context Management (CRASH PREVENTION)
19
223
 
20
224
  **Active increment (10+ tasks) + large file edit (2000+ lines) = CRASH**
21
225
 
@@ -25,7 +229,9 @@ For **contributors to SpecWeave itself** (not users).
25
229
  # OR close completed increments: /sw:done XXXX
26
230
  ```
27
231
 
28
- **Token budget per increment**: ~80k tokens max
232
+ - **Token budget per increment**: ~80k tokens max
233
+ - **Max 25 tasks per increment** (soft limit) - consider splitting if >25
234
+ - **Max 1500 lines/file** (2000+ = crash risk)
29
235
 
30
236
  ### 2. Source of Truth
31
237
 
@@ -37,40 +243,55 @@ Edit("tasks.md", "**Status**: [ ] pending", "**Status**: [x] completed");
37
243
  Edit("spec.md", "- [ ] **AC-US1-01**", "- [x] **AC-US1-01**");
38
244
  ```
39
245
 
40
- ### 3. NEVER Edit metadata.json to "completed" Directly
246
+ ### 3. Status Workflow
41
247
 
42
- **Pre-tool-use hook `completion-guard.sh` BLOCKS direct completion edits.**
248
+ **NEVER edit metadata.json to "completed" directly!**
43
249
 
44
- Correct workflow: All tasks → `ready_for_review` → `/sw:done` → `completed`
250
+ Correct workflow:
251
+ 1. All tasks completed → auto-transition to `ready_for_review`
252
+ 2. `/sw:done <id>` → validates ACs + asks for user confirmation
253
+ 3. Only then → status becomes `completed` with approvedAt timestamp
254
+
255
+ If implementing closure programmatically:
256
+ ```typescript
257
+ MetadataManager.updateStatus(incrementId, IncrementStatus.COMPLETED);
258
+ // Only succeeds if current status is "ready_for_review"
259
+ ```
45
260
 
46
261
  ### 4. Task-AC Auto-Sync (EDA)
47
262
 
48
- Mark task complete in tasks.md Hook auto-checks **Acceptance** points → Hook updates spec.md ACs
263
+ When you mark a task complete in tasks.md, hooks auto-update:
264
+ 1. All **Acceptance** checkboxes in that task: `- [ ]` → `- [x]`
265
+ 2. Corresponding ACs in spec.md: `- [ ] **AC-US1-01**` → `- [x] **AC-US1-01**`
266
+ 3. When ALL tasks complete → auto-transitions to `ready_for_review`
267
+
268
+ ### 5. Per-US **Project**: Fields
49
269
 
50
- ### 5. Per-US **Project**: Fields are MANDATORY
270
+ Every User Story SHOULD have `**Project**:` field for proper sync:
51
271
 
52
- Every User Story MUST have `**Project**:` field. Use value from `config.project.name` or `multiProject.projects`.
272
+ ```markdown
273
+ ### US-001: Login Form
274
+ **Project**: my-project # Use config.project.name or multiProject.projects key
275
+ **As a** user, I want...
276
+ ```
53
277
 
54
- ### 6. NEVER Use Bash for File Creation
278
+ **Each User Story = ONE Project** (and ONE Board for 2-level structures)
55
279
 
56
- **Bash + heredoc/echo = SESSION FREEZE** (shell waits forever for EOF)
280
+ ### 6. File Operations
281
+
282
+ **Use Write/Edit tools for file creation. NEVER use Bash heredoc/echo redirects.**
57
283
 
58
284
  ```
59
285
  ❌ FORBIDDEN: Bash("cat > file.md << 'EOF'...")
60
- MANDATORY: Write({ file_path: "...", content: "..." })
286
+ FORBIDDEN: Bash("echo '...' > file.md")
287
+ ✅ CORRECT: Write({ file_path: "...", content: "..." })
61
288
  ```
62
289
 
63
- **Pre-tool-use hook `bash-file-guard.sh` BLOCKS dangerous patterns.**
64
-
65
290
  ### 7. Protected Directories
66
291
 
67
292
  **NEVER delete**: `.specweave/docs/`, `.specweave/increments/`
68
293
 
69
- ### 8. File Size Limits
70
-
71
- **Max 1500 lines/file** (2000+ = crash risk). Check: `wc -l file.ts`
72
-
73
- ### 9. NEVER Spawn Parallel Agents for Multi-File Migrations
294
+ ### 8. NEVER Spawn Parallel Agents for Multi-File Migrations
74
295
 
75
296
  **Parallel agents reading large files = CRASH** (context shared, not isolated!)
76
297
 
@@ -79,26 +300,144 @@ Every User Story MUST have `**Project**:` field. Use value from `config.project.
79
300
  ✅ CORRECT: Process files ONE BY ONE, use Edit tool directly
80
301
  ```
81
302
 
82
- ### 10. NEVER Create Files in _features/ Folder
303
+ ### 9. Increment Structure
83
304
 
84
- `_features/` is OBSOLETE. Use: `.specweave/docs/internal/specs/{project}/FS-XXX/`
85
-
86
- ### 11. NEVER Create Duplicate Increment IDs
305
+ **Increment root - ONLY**: `spec.md`, `plan.md`, `tasks.md`, `metadata.json`
306
+ **Everything else → subfolders**: `reports/`, `scripts/`, `logs/`, `docs/`
87
307
 
88
- Increment numbers MUST be unique. Gap-filling is automatic (v0.33.1+).
308
+ **Increment IDs MUST be unique** across all directories (including _archive, _abandoned, _paused).
309
+ Use `IncrementNumberManager.generateIncrementId()` - it validates automatically.
89
310
 
90
- ### 12. Skills Must NOT Spawn Large Agents
311
+ ### 10. Skills Must NOT Spawn Large Agents
91
312
 
92
313
  Skills spawning content-generating agents = CRASH (context explosion)
93
314
 
315
+ ### 11. Repository Locations (Multi-Repo)
316
+
317
+ **Clone to `/repositories`, NEVER project root.**
318
+
319
+ ```
320
+ project-root/
321
+ ├── repositories/ # All repos here
322
+ │ ├── frontend/
323
+ │ ├── backend/
324
+ │ └── shared/
325
+ ├── .specweave/ # Config at umbrella level
326
+ └── CLAUDE.md
327
+ ```
328
+
329
+ **Path refs in specs**: `repositories/backend/src/...`
330
+
331
+ ---
332
+
333
+ ## Proactive Agent Usage (USE THE EXPERTS!)
334
+
335
+ **SpecWeave has 40+ specialized agents. USE THEM instead of doing domain work directly!**
336
+
337
+ When the user's request involves specialized domains, **spawn the appropriate agent** via Task tool:
338
+
339
+ ### Agent Quick Reference
340
+
341
+ | Domain | Agent (`subagent_type`) | Triggers |
342
+ |--------|-------------------------|----------|
343
+ | **Architecture** | `specweave:architect:architect` | system design, ADR, technical design, patterns |
344
+ | **Frontend** | `specweave-frontend:frontend-architect:frontend-architect` | React, Vue, Next.js, components, UI |
345
+ | **Backend** | `specweave-backend:database-optimizer:database-optimizer` | API, database, microservices, SQL |
346
+ | **Kubernetes** | `specweave-kubernetes:kubernetes-architect:kubernetes-architect` | K8s, EKS, AKS, GKE, pods, helm, GitOps |
347
+ | **Infrastructure** | `specweave-infrastructure:devops:devops` | Terraform, Docker, CI/CD, AWS, Azure, GCP |
348
+ | **Kafka** | `specweave-kafka:kafka-architect:kafka-architect` | Kafka, topics, event streaming, MSK |
349
+ | **Confluent** | `specweave-confluent:confluent-architect:confluent-architect` | Confluent Cloud, Schema Registry, ksqlDB |
350
+ | **Mobile** | `specweave-mobile:mobile-architect:mobile-architect` | React Native, iOS, Android |
351
+ | **ML/AI** | `specweave-ml:ml-engineer:ml-engineer` | ML, model, training, MLOps |
352
+ | **Data Science** | `specweave-ml:data-scientist:data-scientist` | data analysis, notebooks, pandas |
353
+ | **Testing/QA** | `specweave-testing:qa-engineer:qa-engineer` | E2E, Playwright, Vitest, Jest, QA |
354
+ | **Security** | `specweave:security:security` | security review, OWASP, auth, vulnerabilities |
355
+ | **Performance** | `specweave-infrastructure:performance-engineer:performance-engineer` | optimization, profiling, caching |
356
+ | **Observability** | `specweave-infrastructure:observability-engineer:observability-engineer` | monitoring, Prometheus, Grafana, SLOs |
357
+ | **SRE** | `specweave-infrastructure:sre:sre` | incidents, outages, production debugging |
358
+ | **Network** | `specweave-infrastructure:network-engineer:network-engineer` | networking, VPC, DNS, load balancing |
359
+ | **Diagrams** | `specweave-diagrams:diagrams-architect:diagrams-architect` | Mermaid, C4, architecture diagrams |
360
+ | **Payments** | `specweave-payments:payment-integration:payment-integration` | Stripe, PayPal, checkout, PCI |
361
+ | **Docs** | `specweave:docs-writer:docs-writer` | documentation, README, API docs |
362
+ | **Release** | `specweave-release:release-manager:release-manager` | release, version, changelog, npm publish |
363
+ | **GitHub** | `specweave-github:github-manager:github-manager` | GitHub issues, PRs, sync |
364
+ | **JIRA** | `specweave-jira:jira-manager:jira-manager` | JIRA, epics, stories, sync |
365
+ | **ADO** | `specweave-ado:ado-manager:ado-manager` | Azure DevOps, work items |
366
+
367
+ ### Usage Pattern
368
+
369
+ ```typescript
370
+ // ❌ WRONG: Doing K8s/infra/frontend work directly
371
+ "Let me write the Kubernetes manifests..."
372
+
373
+ // ✅ CORRECT: Spawn the expert agent
374
+ Task({
375
+ subagent_type: "specweave-kubernetes:kubernetes-architect:kubernetes-architect",
376
+ prompt: "Create K8s manifests for a 3-tier web app with Ingress",
377
+ description: "K8s manifests design"
378
+ })
379
+ ```
380
+
381
+ ### When to Use Agents
382
+
383
+ - **ANY architecture decisions** → `specweave:architect:architect`
384
+ - **Infrastructure/DevOps code** → `specweave-infrastructure:devops:devops`
385
+ - **K8s manifests/GitOps** → `specweave-kubernetes:kubernetes-architect:kubernetes-architect`
386
+ - **Frontend components** → `specweave-frontend:frontend-architect:frontend-architect`
387
+ - **Test strategy/E2E** → `specweave-testing:qa-engineer:qa-engineer`
388
+ - **Security review** → `specweave:security:security`
389
+ - **Performance tuning** → `specweave-infrastructure:performance-engineer:performance-engineer`
390
+
391
+ **Rule**: If a plugin/agent exists for the domain, USE IT. Don't reinvent expertise.
392
+
393
+ **Reference**: See `plugins/PLUGINS-INDEX.md` for full plugin catalog with triggers.
394
+
395
+ ---
396
+
397
+ ## Secrets & Service Integration Check (MANDATORY)
398
+
399
+ **BEFORE using CLI tools that require authentication (gh, jira, az, etc.), ALWAYS check for existing configuration:**
400
+
401
+ 1. **Check `.env` file** for tokens/credentials:
402
+ ```bash
403
+ # Look for relevant tokens before running CLI commands
404
+ grep -E "(GITHUB_TOKEN|JIRA_|AZURE_|ADO_)" .env 2>/dev/null
405
+ ```
406
+
407
+ 2. **Check `.specweave/config.json`** for service configuration:
408
+ ```bash
409
+ # Check sync configuration
410
+ cat .specweave/config.json | grep -A 10 '"sync"'
411
+ ```
412
+
413
+ 3. **Check project-specific config files**:
414
+ - `.github/` for GitHub Actions secrets references
415
+ - `package.json` for repository URLs
416
+ - `.specweave/config.json` for external tool settings
417
+
418
+ **Common patterns**:
419
+ ```bash
420
+ # GitHub - check if already authenticated
421
+ gh auth status
422
+
423
+ # JIRA - check configured domain
424
+ grep JIRA .env .specweave/config.json 2>/dev/null
425
+
426
+ # Azure DevOps - check org/project
427
+ grep -E "(ADO_|AZURE_DEVOPS)" .env .specweave/config.json 2>/dev/null
428
+ ```
429
+
430
+ **Rule**: NEVER assume CLI tools are unconfigured. Check first, then use existing credentials.
431
+
94
432
  ---
95
433
 
96
434
  ## Coding Standards
97
435
 
98
- 1. **Logger injection**: ALL `src/` code uses `logger`, NEVER `console.*`
99
- 2. **Imports**: ALWAYS `.js` extensions
100
- 3. **Tests**: `.test.ts` files, `vi.fn()` (not jest), `os.tmpdir()` (not cwd)
101
- 4. **Filesystem**: Native `fs` only (NEVER `fs-extra`)
436
+ - **Logger**: Prefer `logger` over `console.*` in new code (legacy migration ongoing)
437
+ - **Imports**: ALWAYS `.js` extensions (enforced)
438
+ - **Tests**: `.test.ts` files, `vi.fn()` (not jest), `os.tmpdir()` (not cwd)
439
+ - **Filesystem**: Prefer native `fs` (fs-extra only in legacy utils)
440
+ - **Config vs Secrets**: Config in `config.json`, secrets in `.env`
102
441
 
103
442
  ---
104
443
 
@@ -119,115 +458,25 @@ increment: 0001-feature-name
119
458
  title: "Feature Title"
120
459
  ---
121
460
  ### US-001: Feature Name
122
- **Project**: my-project # MANDATORY
461
+ **Project**: my-project
123
462
  **As a** user, I want...
124
463
  ```
125
464
 
126
465
  ### GitHub Issue Format
127
466
  **ONLY**: `[FS-XXX][US-YYY] User Story Title`
128
- **PROHIBITED**: `[SP-*]`, `[FS-XXX]` alone, `[undefined][US-XXX]`
129
467
 
130
468
  ### ADR Naming
131
469
  **Format**: `XXXX-decision-title.md` (4-digit, NO `adr-` prefix)
132
470
  **Location**: `.specweave/docs/internal/architecture/adr/`
133
471
 
134
- ---
135
-
136
- ## Important Rules
137
-
138
- - **NO Increment-to-Increment References**: FORBIDDEN in user stories
139
- - **Structured Data Matching**: Use `deriveFeatureId()`, not `content.includes('FS-039')`
140
- - **GitHub Duplicates**: Use `DuplicateDetector.createWithProtection()`
141
- - **AC Presence in spec.md**: MANDATORY even with external living docs
142
- - **Git Provider Abstraction**: Use `getPlatformRegistry().getProvider('github')`
143
-
144
- ---
145
-
146
- ## Folder Structure
147
-
148
- **Increment root - ONLY**: `spec.md`, `plan.md`, `tasks.md`, `metadata.json`
149
- **Everything else → subfolders**: `reports/`, `scripts/`, `logs/`
150
-
151
472
  ### External Increment E-Suffix
152
473
  ```
153
474
  ✅ 0111E-dora-metrics-fix (external GitHub issue)
154
- ❌ 0111-dora-metrics-fix (missing E suffix)
475
+ ❌ 0111-dora-metrics-fix (missing E suffix for external)
155
476
  ```
156
477
 
157
478
  ---
158
479
 
159
- ## Configuration
160
-
161
- ### Secrets vs Configuration
162
-
163
- **Secrets** (`.env`, gitignored): `AZURE_DEVOPS_PAT`, `JIRA_API_TOKEN`, `GH_TOKEN`
164
- **Config** (`.specweave/config.json`): `issueTracker.domain`, `issueTracker.organization_ado`
165
-
166
- ```typescript
167
- // NEVER: process.env.JIRA_DOMAIN
168
- // ALWAYS: config.issueTracker?.domain
169
- ```
170
-
171
- ---
172
-
173
- ## Hook Development
174
-
175
- ### Hook Input Format
176
-
177
- ```bash
178
- # For Write/Edit (nested in tool_input):
179
- FILE_PATH=$(echo "$INPUT" | jq -r '.tool_input.file_path // .file_path // empty')
180
-
181
- # For Bash (direct):
182
- COMMAND=$(echo "$INPUT" | jq -r '.command // empty')
183
- ```
184
-
185
- ### Hook Return Format
186
- ```bash
187
- echo '{"decision": "allow"}' # Allow
188
- echo '{"decision": "block", "reason": "Error"}' # Block (exit 2)
189
- ```
190
-
191
- ### Hook Concurrency (v1.0.30+)
192
-
193
- All hooks use `fail-fast-wrapper.sh` with:
194
- - **Semaphore**: Max 15 concurrent hooks
195
- - **Circuit Breaker**: 5 failures → OPEN → 30s → HALF_OPEN
196
- - **Metrics**: Latency p50/p95/p99, health score
197
-
198
- ```bash
199
- # Health dashboard
200
- bash plugins/specweave/scripts/hook-health.sh
201
- ```
202
-
203
- ### Hook Architecture (v2)
204
-
205
- ```
206
- hooks/
207
- ├── hooks.json # Hook registration
208
- ├── universal/
209
- │ └── fail-fast-wrapper.sh # Concurrency wrapper
210
- ├── v2/
211
- │ ├── dispatchers/ # Entry points (session-start, post-tool-use)
212
- │ ├── guards/ # PreToolUse blockers (bash-file, completion, metadata-json)
213
- │ ├── handlers/ # PostToolUse actions (living-docs, github-sync, project-bridge)
214
- │ ├── detectors/ # Event detection (us-completion, lifecycle)
215
- │ └── queue/ # Async processing (enqueue, dequeue, processor)
216
- └── lib/ # Shared utilities (semaphore, circuit-breaker, metrics)
217
- ```
218
-
219
- ### Key Hooks
220
-
221
- | Hook | Type | Purpose |
222
- |------|------|---------|
223
- | `bash-file-guard.sh` | PreToolUse | Blocks heredoc/echo file creation |
224
- | `completion-guard.sh` | PreToolUse | Blocks direct metadata.json completion |
225
- | `metadata-json-guard.sh` | PreToolUse | Validates spec.md writes |
226
- | `task-ac-sync-guard.sh` | PostToolUse | Auto-syncs task ACs to spec.md |
227
- | `project-bridge-handler.sh` | PostToolUse | Bridges to external tools (GitHub/JIRA/ADO) |
228
-
229
- ---
230
-
231
480
  ## Commands
232
481
 
233
482
  ```bash
@@ -246,7 +495,7 @@ hooks/
246
495
  ```bash
247
496
  npm run rebuild # Clean + build
248
497
  npm test # Smoke tests
249
- npm run test:all # All tests (30%+ coverage)
498
+ npm run test:all # All tests
250
499
  ```
251
500
 
252
501
  ---
@@ -254,7 +503,6 @@ npm run test:all # All tests (30%+ coverage)
254
503
  ## Emergency
255
504
 
256
505
  ### Session Stuck ("Marinating...")
257
-
258
506
  ```bash
259
507
  # 1. Force quit Claude Code
260
508
  # 2. Kill zombies:
@@ -269,27 +517,13 @@ rm -rf .specweave/state/.dedup-cache/*.lock
269
517
  ### Disable Hooks
270
518
  ```bash
271
519
  export SPECWEAVE_DISABLE_HOOKS=1
272
- # OR rename: mv plugins/specweave/hooks/hooks.json hooks.json.bak
273
- ```
274
-
275
- ### Zombie Processes (AUTO-CLEANUP v0.33.0+)
276
- Session watchdog cleans zombies every 60s automatically.
277
-
278
- ### Marketplace Plugin Desync
279
- ```bash
280
- # Refresh marketplace and reinstall plugins
281
- bash scripts/refresh-marketplace.sh
282
- ```
283
-
284
- ### MCP IDE Connection Drops
285
- ```bash
286
- # Restart VS Code Extension Host: Cmd+Shift+P → "Developer: Restart Extension Host"
287
- # Or run Claude Code in plain terminal instead of VS Code integrated terminal
520
+ # Or bypass specific validations:
521
+ export SPECWEAVE_FORCE_PROJECT=1
522
+ export SPECWEAVE_FORCE_METADATA=1
288
523
  ```
289
524
 
290
525
  ### Crash Loop / Prompt Duplication
291
526
  ```bash
292
- # Clean state:
293
527
  rm -f .specweave/state/.hook-*
294
528
  rm -rf .specweave/state/.dedup-cache
295
529
  npm run rebuild
@@ -301,10 +535,11 @@ npm run rebuild
301
535
 
302
536
  | Aspect | Rule |
303
537
  |--------|------|
304
- | **File ops** | Write/Edit/Read tools ONLY. NEVER Bash heredoc! |
305
- | **Hook input** | Write/Edit: `.tool_input.file_path`, Bash: `.command` |
306
- | **Pre-commit** | Blocks 50+ deletions, `rm -rf` on protected dirs |
307
- | **Stuck session** | Kill + `pkill -f "cat.*EOF"` + clean locks |
538
+ | File ops | Write/Edit/Read tools ONLY |
539
+ | Source of truth | tasks.md + spec.md |
540
+ | Completion | NEVER edit metadata.json directly |
541
+ | Increment root | ONLY spec.md, plan.md, tasks.md, metadata.json |
542
+ | Stuck session | Kill + pkill zombies + clean locks |
308
543
 
309
544
  ---
310
545
 
@@ -312,4 +547,5 @@ npm run rebuild
312
547
 
313
548
  - **Internal Docs**: `.specweave/docs/internal/`
314
549
  - **ADRs**: `.specweave/docs/internal/architecture/adr/`
315
- - **Emergency**: `.specweave/docs/internal/emergency-procedures/`
550
+ - **Troubleshooting**: `.specweave/docs/internal/troubleshooting/`
551
+
package/README.md CHANGED
@@ -14,8 +14,6 @@
14
14
  npm install -g specweave
15
15
  ```
16
16
 
17
- > **v1.0.22** — [Changelog](https://github.com/anton-abyzov/specweave/releases)
18
-
19
17
  ---
20
18
 
21
19
  ## The Problem With AI Coding Tools
package/bin/specweave.js CHANGED
@@ -235,6 +235,17 @@ program
235
235
  console.log(statusLine);
236
236
  });
237
237
 
238
+ // Update instructions command - Smart merge CLAUDE.md/AGENTS.md
239
+ program
240
+ .command('update-instructions')
241
+ .description('Update CLAUDE.md and AGENTS.md with smart merge (preserves user content)')
242
+ .option('--dry-run', 'Preview changes without writing')
243
+ .option('-v, --verbose', 'Show detailed merge information')
244
+ .action(async (options) => {
245
+ const { updateInstructionsCommand } = await import('../dist/src/cli/commands/update-instructions.js');
246
+ await updateInstructionsCommand(options);
247
+ });
248
+
238
249
  // Check discipline command - Validate increment discipline
239
250
  program
240
251
  .command('check-discipline')