specweave 0.1.9 → 0.3.1

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 (293) hide show
  1. package/CLAUDE.md +600 -0
  2. package/README.md +263 -81
  3. package/bin/install-all.sh +1 -1
  4. package/bin/install-commands.sh +3 -3
  5. package/bin/specweave.js +39 -9
  6. package/dist/adapters/adapter-base.d.ts +1 -1
  7. package/dist/adapters/adapter-base.d.ts.map +1 -1
  8. package/dist/adapters/adapter-base.js +6 -41
  9. package/dist/adapters/adapter-base.js.map +1 -1
  10. package/dist/adapters/adapter-interface.js +1 -2
  11. package/dist/adapters/adapter-interface.js.map +1 -1
  12. package/dist/adapters/adapter-loader.d.ts +86 -0
  13. package/dist/adapters/adapter-loader.d.ts.map +1 -0
  14. package/dist/adapters/adapter-loader.js +216 -0
  15. package/dist/adapters/adapter-loader.js.map +1 -0
  16. package/dist/adapters/agents-md-generator.d.ts +48 -0
  17. package/dist/adapters/agents-md-generator.d.ts.map +1 -0
  18. package/dist/adapters/agents-md-generator.js +132 -0
  19. package/dist/adapters/agents-md-generator.js.map +1 -0
  20. package/dist/adapters/claude/adapter.d.ts +2 -2
  21. package/dist/adapters/claude/adapter.d.ts.map +1 -1
  22. package/dist/adapters/claude/adapter.js +5 -42
  23. package/dist/adapters/claude/adapter.js.map +1 -1
  24. package/dist/adapters/claude-md-generator.d.ts +78 -0
  25. package/dist/adapters/claude-md-generator.d.ts.map +1 -0
  26. package/dist/adapters/claude-md-generator.js +246 -0
  27. package/dist/adapters/claude-md-generator.js.map +1 -0
  28. package/dist/adapters/codex/adapter.d.ts +50 -0
  29. package/dist/adapters/codex/adapter.d.ts.map +1 -0
  30. package/dist/adapters/codex/adapter.js +316 -0
  31. package/dist/adapters/codex/adapter.js.map +1 -0
  32. package/dist/adapters/copilot/adapter.d.ts +10 -9
  33. package/dist/adapters/copilot/adapter.d.ts.map +1 -1
  34. package/dist/adapters/copilot/adapter.js +35 -100
  35. package/dist/adapters/copilot/adapter.js.map +1 -1
  36. package/dist/adapters/cursor/adapter.d.ts +8 -6
  37. package/dist/adapters/cursor/adapter.d.ts.map +1 -1
  38. package/dist/adapters/cursor/adapter.js +47 -130
  39. package/dist/adapters/cursor/adapter.js.map +1 -1
  40. package/dist/adapters/doc-generator.d.ts +69 -0
  41. package/dist/adapters/doc-generator.d.ts.map +1 -0
  42. package/dist/adapters/doc-generator.js +247 -0
  43. package/dist/adapters/doc-generator.js.map +1 -0
  44. package/dist/adapters/gemini/adapter.d.ts +50 -0
  45. package/dist/adapters/gemini/adapter.d.ts.map +1 -0
  46. package/dist/adapters/gemini/adapter.js +281 -0
  47. package/dist/adapters/gemini/adapter.js.map +1 -0
  48. package/dist/adapters/generic/adapter.d.ts +7 -4
  49. package/dist/adapters/generic/adapter.d.ts.map +1 -1
  50. package/dist/adapters/generic/adapter.js +60 -59
  51. package/dist/adapters/generic/adapter.js.map +1 -1
  52. package/dist/cli/commands/init.d.ts +3 -1
  53. package/dist/cli/commands/init.d.ts.map +1 -1
  54. package/dist/cli/commands/init.js +327 -177
  55. package/dist/cli/commands/init.js.map +1 -1
  56. package/dist/cli/commands/install.d.ts.map +1 -1
  57. package/dist/cli/commands/install.js +22 -58
  58. package/dist/cli/commands/install.js.map +1 -1
  59. package/dist/cli/commands/list.d.ts.map +1 -1
  60. package/dist/cli/commands/list.js +27 -64
  61. package/dist/cli/commands/list.js.map +1 -1
  62. package/dist/core/credentials-manager.d.ts +90 -0
  63. package/dist/core/credentials-manager.d.ts.map +1 -0
  64. package/dist/core/credentials-manager.js +271 -0
  65. package/dist/core/credentials-manager.js.map +1 -0
  66. package/dist/core/project-structure-detector.d.ts +92 -0
  67. package/dist/core/project-structure-detector.d.ts.map +1 -0
  68. package/dist/core/project-structure-detector.js +289 -0
  69. package/dist/core/project-structure-detector.js.map +1 -0
  70. package/dist/core/rfc-generator-v2.d.ts +149 -0
  71. package/dist/core/rfc-generator-v2.d.ts.map +1 -0
  72. package/dist/core/rfc-generator-v2.js +399 -0
  73. package/dist/core/rfc-generator-v2.js.map +1 -0
  74. package/dist/core/rfc-generator.d.ts +147 -0
  75. package/dist/core/rfc-generator.d.ts.map +1 -0
  76. package/dist/core/rfc-generator.js +434 -0
  77. package/dist/core/rfc-generator.js.map +1 -0
  78. package/dist/integrations/ado/ado-client.d.ts +123 -0
  79. package/dist/integrations/ado/ado-client.d.ts.map +1 -0
  80. package/dist/integrations/ado/ado-client.js +398 -0
  81. package/dist/integrations/ado/ado-client.js.map +1 -0
  82. package/dist/integrations/jira/jira-client.d.ts +139 -0
  83. package/dist/integrations/jira/jira-client.d.ts.map +1 -0
  84. package/dist/integrations/jira/jira-client.js +386 -0
  85. package/dist/integrations/jira/jira-client.js.map +1 -0
  86. package/dist/integrations/jira/jira-incremental-mapper.d.ts +75 -0
  87. package/dist/integrations/jira/jira-incremental-mapper.d.ts.map +1 -0
  88. package/dist/integrations/jira/jira-incremental-mapper.js +474 -0
  89. package/dist/integrations/jira/jira-incremental-mapper.js.map +1 -0
  90. package/dist/integrations/jira/jira-mapper.d.ts +105 -0
  91. package/dist/integrations/jira/jira-mapper.d.ts.map +1 -0
  92. package/dist/integrations/jira/jira-mapper.js +494 -0
  93. package/dist/integrations/jira/jira-mapper.js.map +1 -0
  94. package/dist/testing/test-generator.d.ts +117 -0
  95. package/dist/testing/test-generator.d.ts.map +1 -0
  96. package/dist/testing/test-generator.js +370 -0
  97. package/dist/testing/test-generator.js.map +1 -0
  98. package/dist/utils/auto-install.d.ts +3 -0
  99. package/dist/utils/auto-install.d.ts.map +1 -1
  100. package/dist/utils/auto-install.js +16 -82
  101. package/dist/utils/auto-install.js.map +1 -1
  102. package/dist/utils/esm-helpers.d.ts +50 -0
  103. package/dist/utils/esm-helpers.d.ts.map +1 -0
  104. package/dist/utils/esm-helpers.js +57 -0
  105. package/dist/utils/esm-helpers.js.map +1 -0
  106. package/package.json +16 -7
  107. package/src/adapters/README.md +1 -2
  108. package/src/adapters/adapter-base.ts +6 -3
  109. package/src/adapters/adapter-loader.ts +261 -0
  110. package/src/adapters/agents-md-generator.ts +162 -0
  111. package/src/adapters/claude/README.md +6 -14
  112. package/src/adapters/claude/adapter.ts +4 -4
  113. package/src/adapters/claude-md-generator.ts +311 -0
  114. package/src/adapters/codex/README.md +105 -0
  115. package/src/adapters/codex/adapter.ts +333 -0
  116. package/src/adapters/copilot/adapter.ts +36 -65
  117. package/src/adapters/cursor/README.md +0 -2
  118. package/src/adapters/cursor/adapter.ts +46 -92
  119. package/src/adapters/doc-generator.ts +331 -0
  120. package/src/adapters/gemini/README.md +97 -0
  121. package/src/adapters/gemini/adapter.ts +298 -0
  122. package/src/adapters/generic/adapter.ts +61 -57
  123. package/src/adapters/registry.yaml +86 -25
  124. package/src/agents/devops/AGENT.md +16 -18
  125. package/src/agents/docs-writer/AGENT.md +2 -2
  126. package/src/agents/pm/AGENT.md +1 -50
  127. package/src/commands/README.md +134 -111
  128. package/src/commands/{build.md → specweave.do.md} +141 -69
  129. package/src/commands/{done.md → specweave.done.md} +3 -3
  130. package/src/commands/{inc.md → specweave.inc.md} +4 -4
  131. package/src/commands/{increment.md → specweave.increment.md} +143 -76
  132. package/src/commands/specweave.md +430 -0
  133. package/src/commands/specweave.next.md +495 -0
  134. package/src/commands/{progress.md → specweave.progress.md} +12 -12
  135. package/src/commands/specweave.sync-docs.md +665 -0
  136. package/src/commands/specweave.sync-github.md +269 -0
  137. package/src/commands/specweave.sync-jira.md +197 -0
  138. package/src/commands/{validate.md → specweave.validate.md} +4 -4
  139. package/src/hooks/README.md +19 -29
  140. package/src/hooks/post-task-completion.sh +25 -30
  141. package/src/skills/ado-sync/README.md +1 -36
  142. package/src/skills/bmad-method-expert/SKILL.md +1 -3
  143. package/src/skills/brownfield-analyzer/SKILL.md +429 -23
  144. package/src/skills/brownfield-onboarder/SKILL.md +221 -8
  145. package/src/skills/context-loader/SKILL.md +239 -617
  146. package/src/skills/context-optimizer/SKILL.md +0 -30
  147. package/src/skills/github-sync/SKILL.md +1 -19
  148. package/src/skills/increment-planner/SKILL.md +64 -18
  149. package/src/skills/increment-quality-judge/SKILL.md +1 -36
  150. package/src/skills/jira-sync/README.md +1 -38
  151. package/src/skills/role-orchestrator/README.md +1 -22
  152. package/src/skills/role-orchestrator/SKILL.md +1 -59
  153. package/src/skills/skill-router/SKILL.md +0 -18
  154. package/src/skills/spec-kit-expert/SKILL.md +1 -3
  155. package/src/skills/specweave-detector/SKILL.md +225 -275
  156. package/src/skills/task-builder/README.md +1 -7
  157. package/src/templates/AGENTS.md.template +334 -0
  158. package/src/templates/CLAUDE.md.template +131 -298
  159. package/src/templates/README.md.template +115 -23
  160. package/src/templates/environments/minimal/README.md +0 -1
  161. package/INSTALL.md +0 -848
  162. package/SPECWEAVE.md +0 -743
  163. package/src/adapters/copilot/.github/copilot/instructions.md +0 -376
  164. package/src/adapters/cursor/.cursorrules +0 -325
  165. package/src/adapters/generic/SPECWEAVE-MANUAL.md +0 -676
  166. package/src/commands/create-project.md +0 -528
  167. package/src/commands/generate-docs.md +0 -623
  168. package/src/commands/review-docs.md +0 -331
  169. package/src/commands/sync-github.md +0 -115
  170. package/src/skills/ado-sync/test-cases/test-1.yaml +0 -9
  171. package/src/skills/ado-sync/test-cases/test-2.yaml +0 -8
  172. package/src/skills/ado-sync/test-cases/test-3.yaml +0 -9
  173. package/src/skills/bmad-method-expert/test-cases/test-1-placeholder.yaml +0 -12
  174. package/src/skills/bmad-method-expert/test-cases/test-2-placeholder.yaml +0 -12
  175. package/src/skills/bmad-method-expert/test-cases/test-3-placeholder.yaml +0 -12
  176. package/src/skills/brownfield-analyzer/test-cases/test-1-basic-analysis.yaml +0 -48
  177. package/src/skills/brownfield-analyzer/test-cases/test-2-placeholder.yaml +0 -12
  178. package/src/skills/brownfield-analyzer/test-cases/test-3-placeholder.yaml +0 -12
  179. package/src/skills/brownfield-onboarder/test-cases/test-1-placeholder.yaml +0 -12
  180. package/src/skills/brownfield-onboarder/test-cases/test-2-placeholder.yaml +0 -12
  181. package/src/skills/brownfield-onboarder/test-cases/test-3-placeholder.yaml +0 -12
  182. package/src/skills/calendar-system/test-cases/test-1-placeholder.yaml +0 -12
  183. package/src/skills/calendar-system/test-cases/test-2-placeholder.yaml +0 -12
  184. package/src/skills/calendar-system/test-cases/test-3-placeholder.yaml +0 -12
  185. package/src/skills/context-loader/test-cases/test-1-basic-loading.yaml +0 -39
  186. package/src/skills/context-loader/test-cases/test-2-token-budget-exceeded.yaml +0 -44
  187. package/src/skills/context-loader/test-cases/test-3-section-anchors.yaml +0 -45
  188. package/src/skills/context-optimizer/test-cases/test-1-bug-fix-narrow.yaml +0 -97
  189. package/src/skills/context-optimizer/test-cases/test-2-feature-focused.yaml +0 -109
  190. package/src/skills/context-optimizer/test-cases/test-3-architecture-broad.yaml +0 -98
  191. package/src/skills/cost-optimizer/test-cases/test-1-basic-comparison.yaml +0 -75
  192. package/src/skills/cost-optimizer/test-cases/test-2-budget-constraint.yaml +0 -52
  193. package/src/skills/cost-optimizer/test-cases/test-3-scale-requirement.yaml +0 -63
  194. package/src/skills/cost-optimizer/test-results/README.md +0 -46
  195. package/src/skills/design-system-architect/test-cases/test-1-token-structure.yaml +0 -23
  196. package/src/skills/design-system-architect/test-cases/test-2-component-hierarchy.yaml +0 -24
  197. package/src/skills/design-system-architect/test-cases/test-3-accessibility-checklist.yaml +0 -23
  198. package/src/skills/diagrams-architect/test-cases/test-1-c4-context.yaml +0 -13
  199. package/src/skills/diagrams-architect/test-cases/test-2-sequence-diagram.yaml +0 -13
  200. package/src/skills/diagrams-architect/test-cases/test-3-er-diagram.yaml +0 -13
  201. package/src/skills/diagrams-generator/test-cases/test-1.yaml +0 -9
  202. package/src/skills/diagrams-generator/test-cases/test-2.yaml +0 -9
  203. package/src/skills/diagrams-generator/test-cases/test-3.yaml +0 -8
  204. package/src/skills/docs-updater/test-cases/test-1-placeholder.yaml +0 -12
  205. package/src/skills/docs-updater/test-cases/test-2-placeholder.yaml +0 -12
  206. package/src/skills/docs-updater/test-cases/test-3-placeholder.yaml +0 -12
  207. package/src/skills/dotnet-backend/test-cases/test-1-rest-api.yaml +0 -14
  208. package/src/skills/dotnet-backend/test-cases/test-2-authentication.yaml +0 -13
  209. package/src/skills/dotnet-backend/test-cases/test-3-minimal-api.yaml +0 -13
  210. package/src/skills/e2e-playwright/test-cases/TC-001-basic-navigation.yaml +0 -54
  211. package/src/skills/e2e-playwright/test-cases/TC-002-form-interaction.yaml +0 -64
  212. package/src/skills/e2e-playwright/test-cases/TC-003-specweave-integration.yaml +0 -74
  213. package/src/skills/e2e-playwright/test-cases/TC-004-accessibility-check.yaml +0 -98
  214. package/src/skills/figma-designer/test-cases/test-1-design-system.yaml +0 -13
  215. package/src/skills/figma-designer/test-cases/test-2-component-library.yaml +0 -13
  216. package/src/skills/figma-designer/test-cases/test-3-responsive-layout.yaml +0 -13
  217. package/src/skills/figma-implementer/test-cases/test-1-design-to-react.yaml +0 -13
  218. package/src/skills/figma-implementer/test-cases/test-2-storybook.yaml +0 -13
  219. package/src/skills/figma-implementer/test-cases/test-3-design-tokens.yaml +0 -13
  220. package/src/skills/figma-mcp-connector/test-cases/test-1-read-file-desktop.yaml +0 -22
  221. package/src/skills/figma-mcp-connector/test-cases/test-2-read-file-framelink.yaml +0 -21
  222. package/src/skills/figma-mcp-connector/test-cases/test-3-error-handling.yaml +0 -18
  223. package/src/skills/figma-to-code/test-cases/test-1-token-generation.yaml +0 -29
  224. package/src/skills/figma-to-code/test-cases/test-2-component-generation.yaml +0 -27
  225. package/src/skills/figma-to-code/test-cases/test-3-typescript-generation.yaml +0 -28
  226. package/src/skills/frontend/test-cases/test-1-react-component.yaml +0 -13
  227. package/src/skills/frontend/test-cases/test-2-form-validation.yaml +0 -13
  228. package/src/skills/frontend/test-cases/test-3-state-management.yaml +0 -13
  229. package/src/skills/github-sync/test-cases/test-1-placeholder.yaml +0 -12
  230. package/src/skills/github-sync/test-cases/test-2-placeholder.yaml +0 -12
  231. package/src/skills/github-sync/test-cases/test-3-placeholder.yaml +0 -12
  232. package/src/skills/hetzner-provisioner/test-cases/test-1-basic-provision.yaml +0 -71
  233. package/src/skills/hetzner-provisioner/test-cases/test-2-postgres-provision.yaml +0 -85
  234. package/src/skills/hetzner-provisioner/test-cases/test-3-ssl-config.yaml +0 -126
  235. package/src/skills/hetzner-provisioner/test-results/README.md +0 -259
  236. package/src/skills/increment-planner/test-cases/test-1-basic-feature.yaml +0 -27
  237. package/src/skills/increment-planner/test-cases/test-2-complex-feature.yaml +0 -30
  238. package/src/skills/increment-planner/test-cases/test-3-auto-numbering.yaml +0 -24
  239. package/src/skills/increment-quality-judge/test-cases/test-1-good-spec.yaml +0 -95
  240. package/src/skills/increment-quality-judge/test-cases/test-2-poor-spec.yaml +0 -108
  241. package/src/skills/increment-quality-judge/test-cases/test-3-export-suggestions.yaml +0 -87
  242. package/src/skills/jira-sync/test-cases/test-1.yaml +0 -9
  243. package/src/skills/jira-sync/test-cases/test-2.yaml +0 -9
  244. package/src/skills/jira-sync/test-cases/test-3.yaml +0 -10
  245. package/src/skills/nextjs/test-cases/test-1-app-router.yaml +0 -13
  246. package/src/skills/nextjs/test-cases/test-2-server-actions.yaml +0 -13
  247. package/src/skills/nextjs/test-cases/test-3-api-routes.yaml +0 -13
  248. package/src/skills/nodejs-backend/test-cases/test-1-express-api.yaml +0 -13
  249. package/src/skills/nodejs-backend/test-cases/test-2-prisma-orm.yaml +0 -13
  250. package/src/skills/nodejs-backend/test-cases/test-3-authentication.yaml +0 -13
  251. package/src/skills/notification-system/test-cases/test-1-placeholder.yaml +0 -12
  252. package/src/skills/notification-system/test-cases/test-2-placeholder.yaml +0 -12
  253. package/src/skills/notification-system/test-cases/test-3-placeholder.yaml +0 -12
  254. package/src/skills/python-backend/test-cases/test-1-fastapi-crud.yaml +0 -13
  255. package/src/skills/python-backend/test-cases/test-2-sqlalchemy.yaml +0 -13
  256. package/src/skills/python-backend/test-cases/test-3-authentication.yaml +0 -13
  257. package/src/skills/role-orchestrator/test-cases/test-1-simple-product.yaml +0 -98
  258. package/src/skills/role-orchestrator/test-cases/test-2-quality-gate-failure.yaml +0 -73
  259. package/src/skills/role-orchestrator/test-cases/test-3-security-workflow.yaml +0 -121
  260. package/src/skills/role-orchestrator/test-cases/test-4-parallel-execution.yaml +0 -145
  261. package/src/skills/role-orchestrator/test-cases/test-5-feedback-loops.yaml +0 -149
  262. package/src/skills/skill-creator/test-cases/test-1-placeholder.yaml +0 -12
  263. package/src/skills/skill-creator/test-cases/test-2-placeholder.yaml +0 -12
  264. package/src/skills/skill-creator/test-cases/test-3-placeholder.yaml +0 -12
  265. package/src/skills/skill-router/test-cases/test-1-basic-routing.yaml +0 -33
  266. package/src/skills/skill-router/test-cases/test-2-ambiguous-request.yaml +0 -42
  267. package/src/skills/skill-router/test-cases/test-3-nested-orchestration.yaml +0 -50
  268. package/src/skills/spec-driven-brainstorming/test-cases/TC-001-simple-idea-to-design.yaml +0 -148
  269. package/src/skills/spec-driven-brainstorming/test-cases/TC-002-complex-ultrathink-design.yaml +0 -190
  270. package/src/skills/spec-driven-brainstorming/test-cases/TC-003-unclear-requirements-socratic.yaml +0 -233
  271. package/src/skills/spec-driven-debugging/test-cases/TC-001-simple-auth-bug.yaml +0 -212
  272. package/src/skills/spec-driven-debugging/test-cases/TC-002-race-condition-ultrathink.yaml +0 -461
  273. package/src/skills/spec-driven-debugging/test-cases/TC-003-brownfield-missing-spec.yaml +0 -366
  274. package/src/skills/spec-kit-expert/test-cases/test-1-placeholder.yaml +0 -12
  275. package/src/skills/spec-kit-expert/test-cases/test-2-placeholder.yaml +0 -12
  276. package/src/skills/spec-kit-expert/test-cases/test-3-placeholder.yaml +0 -12
  277. package/src/skills/specweave-ado-mapper/test-cases/test-1-export-to-ado.yaml +0 -13
  278. package/src/skills/specweave-ado-mapper/test-cases/test-2-import-from-ado.yaml +0 -13
  279. package/src/skills/specweave-ado-mapper/test-cases/test-3-bidirectional-sync.yaml +0 -13
  280. package/src/skills/specweave-detector/test-cases/test-1-basic-detection.yaml +0 -37
  281. package/src/skills/specweave-detector/test-cases/test-2-missing-config.yaml +0 -37
  282. package/src/skills/specweave-detector/test-cases/test-3-non-specweave-project.yaml +0 -34
  283. package/src/skills/specweave-jira-mapper/test-cases/test-1-export-to-jira.yaml +0 -13
  284. package/src/skills/specweave-jira-mapper/test-cases/test-2-import-from-jira.yaml +0 -13
  285. package/src/skills/specweave-jira-mapper/test-cases/test-3-sync-status.yaml +0 -13
  286. package/src/skills/stripe-integrator/test-cases/test-1-placeholder.yaml +0 -12
  287. package/src/skills/stripe-integrator/test-cases/test-2-placeholder.yaml +0 -12
  288. package/src/skills/stripe-integrator/test-cases/test-3-placeholder.yaml +0 -12
  289. package/src/skills/task-builder/test-cases/test-1-placeholder.yaml +0 -12
  290. package/src/skills/task-builder/test-cases/test-2-placeholder.yaml +0 -12
  291. package/src/skills/task-builder/test-cases/test-3-placeholder.yaml +0 -12
  292. package/src/templates/config.yaml +0 -351
  293. /package/src/commands/{list-increments.md → specweave.list-increments.md} +0 -0
@@ -0,0 +1,665 @@
1
+ ---
2
+ name: specweave.sync-docs
3
+ description: Bidirectional documentation sync - review strategic docs before implementation OR update living docs from completed increments with conflict resolution
4
+ ---
5
+
6
+ # Sync Documentation
7
+
8
+ You are executing the SpecWeave documentation sync command. This handles bidirectional documentation synchronization between increments and living docs.
9
+
10
+ ---
11
+
12
+ ## STEP 1: Parse Arguments and Detect Mode
13
+
14
+ ```
15
+ Arguments provided: [user's arguments]
16
+ ```
17
+
18
+ **Parse the input**:
19
+ - Check for explicit mode: `review`, `update`, or none (auto-detect)
20
+ - Check for increment ID: `0001`, `0002`, etc., or none (find current)
21
+
22
+ **Auto-detect logic**:
23
+
24
+ 1. **If increment ID provided**:
25
+ ```bash
26
+ # Read the increment's spec.md to check status
27
+ INCREMENT_PATH=".specweave/increments/{increment_id}"
28
+ STATUS=$(grep "^status:" "$INCREMENT_PATH/spec.md" | cut -d: -f2 | tr -d ' ')
29
+ ```
30
+
31
+ 2. **If no increment ID provided**:
32
+ ```bash
33
+ # Find the most recent increment
34
+ LATEST=$(ls -1 .specweave/increments/ | grep -E '^[0-9]{4}' | sort -r | head -1)
35
+ ```
36
+
37
+ 3. **Determine mode**:
38
+ ```
39
+ If status = "planned" → REVIEW MODE
40
+ If status = "in-progress" → UPDATE MODE
41
+ If status = "completed" → UPDATE MODE
42
+ If status = "closed" → UPDATE MODE
43
+
44
+ If explicit mode provided → Use that mode
45
+ ```
46
+
47
+ **Output**:
48
+ ```
49
+ 🔍 Detected increment: {increment_id}
50
+ 📊 Status: {status}
51
+ 🎯 Mode: {REVIEW or UPDATE}
52
+
53
+ Proceeding with {mode} mode...
54
+ ```
55
+
56
+ ---
57
+
58
+ ## STEP 2A: REVIEW MODE (Pre-Implementation)
59
+
60
+ **Execute this if mode = REVIEW**
61
+
62
+ ### Review Mode Purpose
63
+ Present strategic documentation to user for approval before implementation starts.
64
+
65
+ ### Execution Steps:
66
+
67
+ 1. **Locate increment folder**:
68
+ ```bash
69
+ INCREMENT_DIR=".specweave/increments/{increment_id}"
70
+ ```
71
+
72
+ 2. **Read all strategic documentation**:
73
+ ```bash
74
+ # Required files
75
+ SPEC_MD="$INCREMENT_DIR/spec.md"
76
+
77
+ # Optional files
78
+ PM_ANALYSIS="$INCREMENT_DIR/pm-analysis.md"
79
+ ARCHITECTURE="$INCREMENT_DIR/architecture.md"
80
+ INFRASTRUCTURE="$INCREMENT_DIR/infrastructure.md"
81
+ SECURITY="$INCREMENT_DIR/security.md"
82
+ TEST_STRATEGY="$INCREMENT_DIR/test-strategy.md"
83
+ PLAN="$INCREMENT_DIR/plan.md"
84
+ ```
85
+
86
+ 3. **Read related ADRs**:
87
+ ```bash
88
+ # Check for ADRs referenced in plan.md or architecture.md
89
+ ADR_DIR=".specweave/docs/internal/architecture/adr"
90
+ ```
91
+
92
+ 4. **Present comprehensive summary**:
93
+
94
+ ```
95
+ ═══════════════════════════════════════════════════════
96
+ 📋 STRATEGIC DOCUMENTATION REVIEW
97
+ ═══════════════════════════════════════════════════════
98
+
99
+ Increment: {increment_id}
100
+ Title: {title from spec.md}
101
+ Priority: {priority from spec.md}
102
+ Status: {status from spec.md}
103
+
104
+ ───────────────────────────────────────────────────────
105
+ ✅ PRODUCT SPECIFICATION (spec.md)
106
+ ───────────────────────────────────────────────────────
107
+
108
+ [Summarize spec.md content - user stories, requirements, acceptance criteria]
109
+
110
+ {If pm-analysis.md exists:}
111
+ ───────────────────────────────────────────────────────
112
+ ✅ PRODUCT STRATEGY (pm-analysis.md)
113
+ ───────────────────────────────────────────────────────
114
+
115
+ User Personas:
116
+ [List personas with needs and pain points]
117
+
118
+ Business Model:
119
+ [Revenue model, target metrics]
120
+
121
+ Feature Prioritization:
122
+ [P1/P2/P3 breakdown]
123
+
124
+ Success Metrics:
125
+ [Key metrics to track]
126
+
127
+ {If architecture.md exists:}
128
+ ───────────────────────────────────────────────────────
129
+ ✅ SYSTEM ARCHITECTURE (architecture.md)
130
+ ───────────────────────────────────────────────────────
131
+
132
+ Tech Stack:
133
+ [List detected or specified tech stack]
134
+
135
+ System Design:
136
+ [Show Mermaid diagram if present, or describe architecture]
137
+
138
+ Data Models:
139
+ [List key entities and relationships]
140
+
141
+ API Design:
142
+ [List key endpoints or interfaces]
143
+
144
+ Scalability Considerations:
145
+ [Performance targets, scaling strategy]
146
+
147
+ {If ADRs referenced:}
148
+ ───────────────────────────────────────────────────────
149
+ ✅ ARCHITECTURE DECISIONS (ADRs)
150
+ ───────────────────────────────────────────────────────
151
+
152
+ [For each ADR mentioned in plan.md:]
153
+ ADR {number}: {title}
154
+ - Decision: {what was decided}
155
+ - Rationale: {why}
156
+ - Trade-offs: {consequences}
157
+
158
+ {If infrastructure.md exists:}
159
+ ───────────────────────────────────────────────────────
160
+ ✅ INFRASTRUCTURE (infrastructure.md)
161
+ ───────────────────────────────────────────────────────
162
+
163
+ Platform: {platform choice}
164
+ Resources: {compute, storage, database specs}
165
+ Deployment: {deployment strategy}
166
+ Monitoring: {monitoring tools}
167
+ Cost Estimate: {monthly cost breakdown}
168
+
169
+ {If security.md exists:}
170
+ ───────────────────────────────────────────────────────
171
+ ✅ SECURITY (security.md)
172
+ ───────────────────────────────────────────────────────
173
+
174
+ Authentication: {auth strategy}
175
+ Authorization: {authz strategy}
176
+ Data Protection: {encryption, GDPR compliance}
177
+ Security Testing: {security test plan}
178
+
179
+ {If test-strategy.md exists:}
180
+ ───────────────────────────────────────────────────────
181
+ ✅ TEST STRATEGY (test-strategy.md)
182
+ ───────────────────────────────────────────────────────
183
+
184
+ Test Pyramid:
185
+ [E2E, Integration, Unit test breakdown]
186
+
187
+ Coverage Target: {target %}
188
+
189
+ Critical Paths:
190
+ [List critical user journeys to test]
191
+
192
+ {If plan.md exists:}
193
+ ───────────────────────────────────────────────────────
194
+ ⏱️ IMPLEMENTATION PLAN (plan.md)
195
+ ───────────────────────────────────────────────────────
196
+
197
+ Total Tasks: {count}
198
+ Estimated Time: {estimate}
199
+
200
+ Phases:
201
+ [List implementation phases with task ranges]
202
+
203
+ ───────────────────────────────────────────────────────
204
+ 💰 COST & TIMELINE SUMMARY
205
+ ───────────────────────────────────────────────────────
206
+
207
+ Infrastructure: ${monthly cost}/month
208
+ External Services: ${services cost}/month
209
+ Total Monthly: ${total}/month
210
+
211
+ Development Time: {weeks} weeks
212
+ Launch Target: {date estimate}
213
+
214
+ ═══════════════════════════════════════════════════════
215
+
216
+ ❓ Do you approve this plan?
217
+
218
+ Options:
219
+ ✅ Type "approve" - Proceed with implementation
220
+ ⚠️ Type "changes" - Request specific updates
221
+ 📋 Type "questions" - Ask clarifying questions
222
+ 🔄 Type "regenerate" - Regenerate strategic analysis
223
+
224
+ ───────────────────────────────────────────────────────
225
+ ```
226
+
227
+ 5. **Wait for user response**:
228
+ - If "approve" → Say: "✅ Strategic documentation approved. Ready to proceed with `/do` command."
229
+ - If "changes" → Ask: "What would you like to change? (architecture/features/security/infrastructure/other)"
230
+ - If "questions" → Ask: "What questions do you have?"
231
+ - If "regenerate" → Ask: "Which section should I regenerate?"
232
+
233
+ **STOP HERE for review mode** - Do not proceed to update mode.
234
+
235
+ ---
236
+
237
+ ## STEP 2B: UPDATE MODE (Post-Implementation)
238
+
239
+ **Execute this if mode = UPDATE**
240
+
241
+ ### Update Mode Purpose
242
+ Synchronize living documentation in `.specweave/docs/` with learnings and decisions from completed or in-progress increment.
243
+
244
+ ### Execution Steps:
245
+
246
+ #### 1. Analyze Increment Artifacts
247
+
248
+ ```bash
249
+ INCREMENT_DIR=".specweave/increments/{increment_id}"
250
+
251
+ # Read all increment files
252
+ SPEC="$INCREMENT_DIR/spec.md"
253
+ PLAN="$INCREMENT_DIR/plan.md"
254
+ ARCHITECTURE="$INCREMENT_DIR/architecture.md"
255
+ SECURITY="$INCREMENT_DIR/security.md"
256
+ INFRASTRUCTURE="$INCREMENT_DIR/infrastructure.md"
257
+ REPORTS_DIR="$INCREMENT_DIR/reports"
258
+
259
+ # List all report files
260
+ REPORTS=$(ls -1 "$REPORTS_DIR"/*.md 2>/dev/null)
261
+ ```
262
+
263
+ **Extract documentation updates**:
264
+
265
+ ```
266
+ Reading increment {increment_id}...
267
+
268
+ 📄 Files found:
269
+ ✓ spec.md
270
+ {✓ or ✗ for each optional file}
271
+ ✓ {count} reports in reports/
272
+
273
+ 🔍 Analyzing for documentation updates...
274
+ ```
275
+
276
+ #### 2. Identify Documentation Targets
277
+
278
+ **Map increment content to living docs locations**:
279
+
280
+ ```yaml
281
+ # Mapping rules:
282
+ spec.md (new features):
283
+ → .specweave/docs/public/overview/features.md
284
+ → .specweave/docs/public/guides/ (if guides section present)
285
+
286
+ spec.md (API changes):
287
+ → .specweave/docs/public/api/ (if exists)
288
+
289
+ plan.md (architecture decisions):
290
+ → .specweave/docs/internal/architecture/adr/NNNN-decision-name.md (create new ADR)
291
+
292
+ plan.md (tech stack changes):
293
+ → .specweave/docs/internal/architecture/README.md
294
+
295
+ architecture.md:
296
+ → .specweave/docs/internal/architecture/diagrams/ (extract diagrams)
297
+ → .specweave/docs/internal/architecture/system-design.md
298
+
299
+ security.md:
300
+ → .specweave/docs/internal/security/
301
+
302
+ infrastructure.md:
303
+ → .specweave/docs/internal/operations/deployment.md
304
+ → .specweave/docs/internal/operations/infrastructure.md
305
+
306
+ reports/*.md (learnings):
307
+ → .specweave/docs/internal/delivery/guides/
308
+ → .specweave/docs/internal/architecture/ (if architectural learnings)
309
+
310
+ test-strategy.md:
311
+ → .specweave/docs/internal/testing/
312
+ ```
313
+
314
+ **Output**:
315
+ ```
316
+ 📊 Documentation updates identified:
317
+
318
+ 1. New ADR needed: {decision from plan.md}
319
+ Target: .specweave/docs/internal/architecture/adr/NNNN-{slug}.md
320
+
321
+ 2. Feature list update: {feature from spec.md}
322
+ Target: .specweave/docs/public/overview/features.md
323
+
324
+ 3. Architecture diagram update: {diagram from architecture.md}
325
+ Target: .specweave/docs/internal/architecture/diagrams/{name}.md
326
+
327
+ {... list all updates}
328
+
329
+ Total: {count} documentation updates
330
+ ```
331
+
332
+ #### 3. Detect Conflicts
333
+
334
+ **For each target file that already exists**:
335
+
336
+ 1. **Read existing content**
337
+ 2. **Read new content from increment**
338
+ 3. **Compare and detect conflicts**:
339
+
340
+ ```javascript
341
+ function detectConflict(existingContent, newContent, section) {
342
+ // Types of conflicts:
343
+
344
+ // 1. Addition (no conflict)
345
+ if (!existingContent.includes(section) && newContent.includes(section)) {
346
+ return { type: 'addition', conflict: false };
347
+ }
348
+
349
+ // 2. Enhancement (minor conflict - check if contradictory)
350
+ if (existingContent.includes(section) && newContent.includes(section)) {
351
+ // Check if new content contradicts existing
352
+ if (isContradictory(existingContent, newContent)) {
353
+ return { type: 'contradiction', conflict: true };
354
+ } else {
355
+ return { type: 'enhancement', conflict: false };
356
+ }
357
+ }
358
+
359
+ // 3. Removal (conflict)
360
+ if (existingContent.includes(section) && !newContent.includes(section)) {
361
+ return { type: 'removal', conflict: true };
362
+ }
363
+
364
+ return { type: 'no_change', conflict: false };
365
+ }
366
+ ```
367
+
368
+ **Conflict detection heuristics**:
369
+ - Keywords that indicate contradiction: "instead of", "rather than", "changed from", "no longer", "deprecated"
370
+ - Architecture decisions with different choices (PostgreSQL vs MongoDB)
371
+ - Security policies with different rules
372
+ - API endpoints with different signatures
373
+
374
+ **Output**:
375
+ ```
376
+ 🔍 Conflict detection results:
377
+
378
+ ✅ No conflict: {count} additions/enhancements
379
+ ⚠️ Conflicts found: {count} contradictions/removals
380
+
381
+ {If conflicts found, list them}
382
+ ```
383
+
384
+ #### 4. Resolve Conflicts (If Any)
385
+
386
+ **For each conflict, present to user**:
387
+
388
+ ```
389
+ ═══════════════════════════════════════════════════════
390
+ ⚠️ CONFLICT #{n}/{total}
391
+ ═══════════════════════════════════════════════════════
392
+
393
+ File: {target_file_path}
394
+ Section: {section_name}
395
+ Conflict Type: {contradiction/removal}
396
+
397
+ ───────────────────────────────────────────────────────
398
+ 📄 EXISTING CONTENT
399
+ ───────────────────────────────────────────────────────
400
+ {show existing content with context - 5 lines before/after}
401
+
402
+ ───────────────────────────────────────────────────────
403
+ 🆕 NEW CONTENT (from increment {increment_id})
404
+ ───────────────────────────────────────────────────────
405
+ {show new content with context}
406
+
407
+ ───────────────────────────────────────────────────────
408
+ ❓ How should I resolve this?
409
+ ───────────────────────────────────────────────────────
410
+
411
+ A) Keep existing only
412
+ B) Replace with new only
413
+ C) Merge both (document the evolution)
414
+ D) Show me more context
415
+ E) Skip this update
416
+
417
+ {If architecture decision:}
418
+ 💡 Recommendation: Option C - Create new ADR documenting the change
419
+
420
+ Your choice (A/B/C/D/E):
421
+ ```
422
+
423
+ **Wait for user input, then record decision**
424
+
425
+ #### 5. Apply Updates
426
+
427
+ **For each update (non-conflicting + resolved conflicts)**:
428
+
429
+ 1. **If creating new file**:
430
+ ```bash
431
+ TARGET_FILE="{path}"
432
+ mkdir -p "$(dirname "$TARGET_FILE")"
433
+ cat > "$TARGET_FILE" <<EOF
434
+ {content}
435
+ EOF
436
+ ```
437
+
438
+ Output: `✅ Created: {file_path}`
439
+
440
+ 2. **If updating existing file**:
441
+ ```bash
442
+ # Backup first
443
+ cp "$TARGET_FILE" "$TARGET_FILE.backup"
444
+
445
+ # Apply update (append, replace section, or merge)
446
+ {update logic based on user choice}
447
+ ```
448
+
449
+ Output: `✅ Updated: {file_path}`
450
+
451
+ 3. **If creating new ADR**:
452
+ ```bash
453
+ # Get next ADR number
454
+ NEXT_ADR=$(ls -1 .specweave/docs/internal/architecture/adr/ | grep -E '^[0-9]{4}' | sort -r | head -1 | cut -d- -f1)
455
+ NEXT_ADR=$((NEXT_ADR + 1))
456
+ NEXT_ADR=$(printf "%04d" $NEXT_ADR)
457
+
458
+ ADR_FILE=".specweave/docs/internal/architecture/adr/${NEXT_ADR}-{slug}.md"
459
+ ```
460
+
461
+ **ADR Template**:
462
+ ```markdown
463
+ # ADR-{number}: {Title}
464
+
465
+ **Status**: Accepted
466
+ **Date**: {current_date}
467
+ **Deciders**: {team}
468
+ **Supersedes**: {previous_adr if applicable}
469
+
470
+ ## Context
471
+
472
+ {describe the problem/decision point from increment}
473
+
474
+ ## Decision
475
+
476
+ {what was decided during implementation}
477
+
478
+ ## Rationale
479
+
480
+ {why this decision was made - from plan.md or reports/}
481
+
482
+ ## Consequences
483
+
484
+ ### Positive
485
+ {benefits}
486
+
487
+ ### Negative
488
+ {trade-offs or limitations}
489
+
490
+ ## Implementation
491
+
492
+ {how it was implemented - reference increment {increment_id}}
493
+
494
+ ## Related
495
+
496
+ - Increment: {increment_id}
497
+ - {other related ADRs}
498
+ ```
499
+
500
+ Output: `✅ Created ADR: {adr_file}`
501
+
502
+ #### 6. Summary Report
503
+
504
+ ```
505
+ ═══════════════════════════════════════════════════════
506
+ ✅ DOCUMENTATION SYNC COMPLETE
507
+ ═══════════════════════════════════════════════════════
508
+
509
+ Increment: {increment_id} ({title})
510
+ Status: {status} → Documentation Updated
511
+
512
+ ───────────────────────────────────────────────────────
513
+ 📊 CHANGES SUMMARY
514
+ ───────────────────────────────────────────────────────
515
+
516
+ Created:
517
+ {list of new files with paths}
518
+ Total: {count} files
519
+
520
+ Updated:
521
+ {list of updated files with paths}
522
+ Total: {count} files
523
+
524
+ ADRs Generated:
525
+ {list of new ADRs}
526
+ Total: {count} ADRs
527
+
528
+ Skipped:
529
+ {list of skipped updates due to user choice}
530
+ Total: {count} updates
531
+
532
+ ───────────────────────────────────────────────────────
533
+ 💾 BACKUPS
534
+ ───────────────────────────────────────────────────────
535
+
536
+ {If any files were updated:}
537
+ Backup files created: {count}
538
+ Location: {original_file}.backup
539
+
540
+ To restore: cp {file}.backup {file}
541
+
542
+ ───────────────────────────────────────────────────────
543
+ 🎯 NEXT STEPS
544
+ ───────────────────────────────────────────────────────
545
+
546
+ 1. Review updated documentation:
547
+ - Public docs: .specweave/docs/public/
548
+ - Internal docs: .specweave/docs/internal/
549
+ - New ADRs: .specweave/docs/internal/architecture/adr/
550
+
551
+ 2. (Optional) Generate Docusaurus site:
552
+ - Use 'docusaurus' skill to publish updated docs
553
+
554
+ 3. Commit changes:
555
+ git add .specweave/docs/
556
+ git commit -m "docs: sync from increment {increment_id}"
557
+
558
+ ═══════════════════════════════════════════════════════
559
+
560
+ Documentation is now in sync with increment {increment_id}! 🎉
561
+ ```
562
+
563
+ ---
564
+
565
+ ## STEP 3: Configuration Support
566
+
567
+ **Check for user configuration** (optional):
568
+
569
+
570
+
571
+ **If config exists, respect it**. If not, use defaults shown above.
572
+
573
+ ---
574
+
575
+ ## ERROR HANDLING
576
+
577
+ ### Error: Increment Not Found
578
+ ```
579
+ ❌ Error: Increment '{increment_id}' not found
580
+
581
+ Available increments:
582
+ {list .specweave/increments/*/}
583
+
584
+ Usage: /sync-docs [review|update] [increment_id]
585
+ ```
586
+
587
+ ### Error: No Increment Files
588
+ ```
589
+ ❌ Error: Increment '{increment_id}' has no spec.md
590
+
591
+ This increment may be incomplete. Expected files:
592
+ - spec.md (required)
593
+ - plan.md (optional)
594
+ - architecture.md (optional)
595
+
596
+ Cannot proceed with sync.
597
+ ```
598
+
599
+ ### Error: Invalid Mode
600
+ ```
601
+ ❌ Error: Invalid mode '{mode}'
602
+
603
+ Valid modes:
604
+ - review (pre-implementation doc review)
605
+ - update (post-implementation doc sync)
606
+ - [none] (auto-detect based on status)
607
+
608
+ Usage: /sync-docs [review|update] [increment_id]
609
+ ```
610
+
611
+ ---
612
+
613
+ ## EXAMPLES
614
+
615
+ ### Example 1: Auto-detect mode for current increment
616
+ ```
617
+ User: /sync-docs
618
+
619
+ Output:
620
+ 🔍 Detected increment: 0002
621
+ 📊 Status: completed
622
+ 🎯 Mode: UPDATE
623
+
624
+ Proceeding with UPDATE mode...
625
+ {... executes update mode}
626
+ ```
627
+
628
+ ### Example 2: Explicit review mode
629
+ ```
630
+ User: /sync-docs review 0003
631
+
632
+ Output:
633
+ 🔍 Increment: 0003
634
+ 📊 Status: planned
635
+ 🎯 Mode: REVIEW
636
+
637
+ {... shows strategic documentation summary}
638
+ ```
639
+
640
+ ### Example 3: Explicit update mode with increment
641
+ ```
642
+ User: /sync-docs update 0002
643
+
644
+ Output:
645
+ 🔍 Increment: 0002
646
+ 📊 Status: completed
647
+ 🎯 Mode: UPDATE
648
+
649
+ {... executes update mode with conflict resolution}
650
+ ```
651
+
652
+ ---
653
+
654
+ ## IMPORTANT NOTES
655
+
656
+ 1. **Always show progress**: Keep user informed at each step
657
+ 2. **Always ask on conflicts**: Never overwrite without user approval
658
+ 3. **Always create backups**: Before modifying existing files
659
+ 4. **Always provide summary**: Show what changed at the end
660
+ 5. **Never skip validation**: Check files exist before reading
661
+ 6. **Never assume structure**: Verify .specweave/docs/ structure exists
662
+
663
+ ---
664
+
665
+ **You are now ready to execute this command. Follow the steps above precisely.**