@bhargavvc/sdd-cc 1.30.1 → 1.35.0

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 (242) hide show
  1. package/README.ja-JP.md +144 -110
  2. package/README.ko-KR.md +143 -107
  3. package/README.md +183 -112
  4. package/README.pt-BR.md +90 -52
  5. package/README.zh-CN.md +141 -101
  6. package/agents/sdd-advisor-researcher.md +23 -0
  7. package/agents/sdd-ai-researcher.md +133 -0
  8. package/agents/sdd-code-fixer.md +516 -0
  9. package/agents/sdd-code-reviewer.md +355 -0
  10. package/agents/sdd-codebase-mapper.md +3 -3
  11. package/agents/sdd-debugger.md +17 -5
  12. package/agents/sdd-doc-verifier.md +201 -0
  13. package/agents/sdd-doc-writer.md +602 -0
  14. package/agents/sdd-domain-researcher.md +153 -0
  15. package/agents/sdd-eval-auditor.md +164 -0
  16. package/agents/sdd-eval-planner.md +154 -0
  17. package/agents/sdd-executor.md +87 -4
  18. package/agents/sdd-framework-selector.md +160 -0
  19. package/agents/sdd-intel-updater.md +314 -0
  20. package/agents/sdd-nyquist-auditor.md +1 -1
  21. package/agents/sdd-phase-researcher.md +71 -4
  22. package/agents/sdd-plan-checker.md +100 -6
  23. package/agents/sdd-planner.md +145 -206
  24. package/agents/sdd-project-researcher.md +25 -2
  25. package/agents/sdd-research-synthesizer.md +3 -3
  26. package/agents/sdd-roadmapper.md +6 -6
  27. package/agents/sdd-security-auditor.md +128 -0
  28. package/agents/sdd-ui-auditor.md +43 -3
  29. package/agents/sdd-ui-checker.md +5 -5
  30. package/agents/sdd-ui-researcher.md +27 -4
  31. package/agents/sdd-user-profiler.md +2 -2
  32. package/agents/sdd-verifier.md +142 -22
  33. package/bin/install.js +2145 -545
  34. package/commands/sdd/add-backlog.md +5 -5
  35. package/commands/sdd/add-tests.md +2 -2
  36. package/commands/sdd/ai-integration-phase.md +36 -0
  37. package/commands/sdd/analyze-dependencies.md +34 -0
  38. package/commands/sdd/audit-fix.md +33 -0
  39. package/commands/sdd/autonomous.md +7 -2
  40. package/commands/sdd/cleanup.md +5 -0
  41. package/commands/sdd/code-review-fix.md +52 -0
  42. package/commands/sdd/code-review.md +55 -0
  43. package/commands/sdd/complete-milestone.md +6 -6
  44. package/commands/sdd/debug.md +22 -9
  45. package/commands/sdd/discuss-phase.md +7 -2
  46. package/commands/sdd/do.md +1 -1
  47. package/commands/sdd/docs-update.md +48 -0
  48. package/commands/sdd/eval-review.md +32 -0
  49. package/commands/sdd/execute-phase.md +4 -0
  50. package/commands/sdd/explore.md +27 -0
  51. package/commands/sdd/fast.md +2 -2
  52. package/commands/sdd/from-sdd2.md +45 -0
  53. package/commands/sdd/help.md +2 -0
  54. package/commands/sdd/import.md +36 -0
  55. package/commands/sdd/intel.md +179 -0
  56. package/commands/sdd/join-discord.md +2 -1
  57. package/commands/sdd/manager.md +1 -0
  58. package/commands/sdd/map-codebase.md +3 -3
  59. package/commands/sdd/new-milestone.md +1 -1
  60. package/commands/sdd/new-project.md +5 -1
  61. package/commands/sdd/new-workspace.md +1 -1
  62. package/commands/sdd/next.md +2 -0
  63. package/commands/sdd/plan-milestone-gaps.md +2 -2
  64. package/commands/sdd/plan-phase.md +6 -1
  65. package/commands/sdd/plant-seed.md +1 -1
  66. package/commands/sdd/profile-user.md +1 -1
  67. package/commands/sdd/quick.md +5 -3
  68. package/commands/sdd/reapply-patches.md +230 -42
  69. package/commands/sdd/research-phase.md +3 -3
  70. package/commands/sdd/review-backlog.md +1 -0
  71. package/commands/sdd/review.md +6 -3
  72. package/commands/sdd/scan.md +26 -0
  73. package/commands/sdd/secure-phase.md +35 -0
  74. package/commands/sdd/ship.md +1 -1
  75. package/commands/sdd/thread.md +5 -5
  76. package/commands/sdd/undo.md +34 -0
  77. package/commands/sdd/verify-work.md +1 -1
  78. package/commands/sdd/workstreams.md +17 -11
  79. package/hooks/dist/sdd-check-update.js +33 -8
  80. package/hooks/dist/sdd-context-monitor.js +17 -8
  81. package/hooks/dist/sdd-phase-boundary.sh +27 -0
  82. package/hooks/dist/sdd-prompt-guard.js +1 -0
  83. package/hooks/dist/sdd-read-guard.js +82 -0
  84. package/hooks/dist/sdd-session-state.sh +33 -0
  85. package/hooks/dist/sdd-statusline.js +137 -15
  86. package/hooks/dist/sdd-validate-commit.sh +47 -0
  87. package/hooks/dist/sdd-workflow-guard.js +4 -4
  88. package/hooks/sdd-check-update.js +139 -0
  89. package/hooks/sdd-context-monitor.js +165 -0
  90. package/hooks/sdd-phase-boundary.sh +27 -0
  91. package/hooks/sdd-prompt-guard.js +97 -0
  92. package/hooks/sdd-read-guard.js +82 -0
  93. package/hooks/sdd-session-state.sh +33 -0
  94. package/hooks/sdd-statusline.js +241 -0
  95. package/hooks/sdd-validate-commit.sh +47 -0
  96. package/hooks/sdd-workflow-guard.js +94 -0
  97. package/package.json +3 -3
  98. package/scripts/build-hooks.js +18 -7
  99. package/scripts/prompt-injection-scan.sh +1 -0
  100. package/scripts/rebrand-gsd-to-sdd.sh +221 -220
  101. package/scripts/run-tests.cjs +5 -1
  102. package/scripts/sync-upstream.sh +1 -1
  103. package/sdd/bin/lib/commands.cjs +79 -17
  104. package/sdd/bin/lib/config.cjs +90 -48
  105. package/sdd/bin/lib/core.cjs +452 -87
  106. package/sdd/bin/lib/docs.cjs +267 -0
  107. package/sdd/bin/lib/frontmatter.cjs +381 -336
  108. package/sdd/bin/lib/init.cjs +110 -16
  109. package/sdd/bin/lib/intel.cjs +660 -0
  110. package/sdd/bin/lib/learnings.cjs +378 -0
  111. package/sdd/bin/lib/milestone.cjs +42 -11
  112. package/sdd/bin/lib/model-profiles.cjs +17 -15
  113. package/sdd/bin/lib/phase.cjs +367 -288
  114. package/sdd/bin/lib/profile-output.cjs +106 -10
  115. package/sdd/bin/lib/roadmap.cjs +146 -115
  116. package/sdd/bin/lib/schema-detect.cjs +238 -0
  117. package/sdd/bin/lib/sdd2-import.cjs +511 -0
  118. package/sdd/bin/lib/security.cjs +124 -3
  119. package/sdd/bin/lib/state.cjs +648 -264
  120. package/sdd/bin/lib/template.cjs +8 -4
  121. package/sdd/bin/lib/verify.cjs +209 -28
  122. package/sdd/bin/lib/workstream.cjs +7 -3
  123. package/sdd/bin/sdd-tools.cjs +184 -12
  124. package/sdd/contexts/dev.md +21 -0
  125. package/sdd/contexts/research.md +22 -0
  126. package/sdd/contexts/review.md +22 -0
  127. package/sdd/references/agent-contracts.md +79 -0
  128. package/sdd/references/ai-evals.md +156 -0
  129. package/sdd/references/ai-frameworks.md +186 -0
  130. package/sdd/references/artifact-types.md +113 -0
  131. package/sdd/references/common-bug-patterns.md +114 -0
  132. package/sdd/references/context-budget.md +49 -0
  133. package/sdd/references/continuation-format.md +25 -25
  134. package/sdd/references/domain-probes.md +125 -0
  135. package/sdd/references/few-shot-examples/plan-checker.md +73 -0
  136. package/sdd/references/few-shot-examples/verifier.md +109 -0
  137. package/sdd/references/gate-prompts.md +100 -0
  138. package/sdd/references/gates.md +70 -0
  139. package/sdd/references/git-integration.md +1 -1
  140. package/sdd/references/ios-scaffold.md +123 -0
  141. package/sdd/references/model-profile-resolution.md +2 -0
  142. package/sdd/references/model-profiles.md +24 -18
  143. package/sdd/references/planner-gap-closure.md +62 -0
  144. package/sdd/references/planner-reviews.md +39 -0
  145. package/sdd/references/planner-revision.md +87 -0
  146. package/sdd/references/planning-config.md +252 -0
  147. package/sdd/references/revision-loop.md +97 -0
  148. package/sdd/references/thinking-models-debug.md +44 -0
  149. package/sdd/references/thinking-models-execution.md +50 -0
  150. package/sdd/references/thinking-models-planning.md +62 -0
  151. package/sdd/references/thinking-models-research.md +50 -0
  152. package/sdd/references/thinking-models-verification.md +55 -0
  153. package/sdd/references/thinking-partner.md +96 -0
  154. package/sdd/references/ui-brand.md +4 -4
  155. package/sdd/references/universal-anti-patterns.md +63 -0
  156. package/sdd/references/verification-overrides.md +227 -0
  157. package/sdd/references/workstream-flag.md +56 -3
  158. package/sdd/templates/AI-SPEC.md +246 -0
  159. package/sdd/templates/DEBUG.md +1 -1
  160. package/sdd/templates/SECURITY.md +61 -0
  161. package/sdd/templates/UAT.md +4 -4
  162. package/sdd/templates/VALIDATION.md +4 -4
  163. package/sdd/templates/claude-md.md +32 -9
  164. package/sdd/templates/config.json +4 -0
  165. package/sdd/templates/debug-subagent-prompt.md +1 -1
  166. package/sdd/templates/dev-preferences.md +1 -1
  167. package/sdd/templates/discovery.md +2 -2
  168. package/sdd/templates/phase-prompt.md +1 -1
  169. package/sdd/templates/planner-subagent-prompt.md +3 -3
  170. package/sdd/templates/project.md +1 -1
  171. package/sdd/templates/research.md +1 -1
  172. package/sdd/templates/state.md +2 -2
  173. package/sdd/workflows/add-phase.md +8 -8
  174. package/sdd/workflows/add-tests.md +12 -9
  175. package/sdd/workflows/add-todo.md +5 -3
  176. package/sdd/workflows/ai-integration-phase.md +284 -0
  177. package/sdd/workflows/analyze-dependencies.md +96 -0
  178. package/sdd/workflows/audit-fix.md +157 -0
  179. package/sdd/workflows/audit-milestone.md +11 -11
  180. package/sdd/workflows/audit-uat.md +2 -2
  181. package/sdd/workflows/autonomous.md +195 -27
  182. package/sdd/workflows/check-todos.md +12 -10
  183. package/sdd/workflows/cleanup.md +2 -0
  184. package/sdd/workflows/code-review-fix.md +497 -0
  185. package/sdd/workflows/code-review.md +515 -0
  186. package/sdd/workflows/complete-milestone.md +56 -22
  187. package/sdd/workflows/diagnose-issues.md +10 -3
  188. package/sdd/workflows/discovery-phase.md +5 -3
  189. package/sdd/workflows/discuss-phase-assumptions.md +24 -6
  190. package/sdd/workflows/discuss-phase-power.md +291 -0
  191. package/sdd/workflows/discuss-phase.md +173 -21
  192. package/sdd/workflows/do.md +23 -21
  193. package/sdd/workflows/docs-update.md +1155 -0
  194. package/sdd/workflows/eval-review.md +155 -0
  195. package/sdd/workflows/execute-phase.md +594 -38
  196. package/sdd/workflows/execute-plan.md +67 -96
  197. package/sdd/workflows/explore.md +139 -0
  198. package/sdd/workflows/fast.md +5 -5
  199. package/sdd/workflows/forensics.md +2 -2
  200. package/sdd/workflows/health.md +4 -4
  201. package/sdd/workflows/help.md +122 -119
  202. package/sdd/workflows/import.md +276 -0
  203. package/sdd/workflows/inbox.md +387 -0
  204. package/sdd/workflows/insert-phase.md +7 -7
  205. package/sdd/workflows/list-phase-assumptions.md +4 -4
  206. package/sdd/workflows/list-workspaces.md +2 -2
  207. package/sdd/workflows/manager.md +35 -32
  208. package/sdd/workflows/map-codebase.md +7 -5
  209. package/sdd/workflows/milestone-summary.md +2 -2
  210. package/sdd/workflows/new-milestone.md +17 -9
  211. package/sdd/workflows/new-project.md +50 -25
  212. package/sdd/workflows/new-workspace.md +7 -5
  213. package/sdd/workflows/next.md +67 -11
  214. package/sdd/workflows/note.md +9 -7
  215. package/sdd/workflows/pause-work.md +75 -12
  216. package/sdd/workflows/plan-milestone-gaps.md +8 -8
  217. package/sdd/workflows/plan-phase.md +294 -42
  218. package/sdd/workflows/plant-seed.md +6 -3
  219. package/sdd/workflows/pr-branch.md +42 -14
  220. package/sdd/workflows/profile-user.md +9 -7
  221. package/sdd/workflows/progress.md +45 -45
  222. package/sdd/workflows/quick.md +195 -47
  223. package/sdd/workflows/remove-phase.md +6 -6
  224. package/sdd/workflows/remove-workspace.md +3 -1
  225. package/sdd/workflows/research-phase.md +2 -2
  226. package/sdd/workflows/resume-project.md +12 -12
  227. package/sdd/workflows/review.md +109 -9
  228. package/sdd/workflows/scan.md +102 -0
  229. package/sdd/workflows/secure-phase.md +166 -0
  230. package/sdd/workflows/session-report.md +2 -2
  231. package/sdd/workflows/settings.md +38 -12
  232. package/sdd/workflows/ship.md +21 -9
  233. package/sdd/workflows/stats.md +1 -1
  234. package/sdd/workflows/transition.md +23 -23
  235. package/sdd/workflows/ui-phase.md +15 -7
  236. package/sdd/workflows/ui-review.md +29 -4
  237. package/sdd/workflows/undo.md +314 -0
  238. package/sdd/workflows/update.md +171 -20
  239. package/sdd/workflows/validate-phase.md +6 -4
  240. package/sdd/workflows/verify-phase.md +210 -6
  241. package/sdd/workflows/verify-work.md +83 -9
  242. package/sdd/commands/sdd/workstreams.md +0 -63
@@ -1,10 +1,13 @@
1
1
  ---
2
+ name: sdd:reapply-patches
2
3
  description: Reapply local modifications after a SDD update
3
4
  allowed-tools: Read, Write, Edit, Bash, Glob, Grep, AskUserQuestion
4
5
  ---
5
6
 
6
7
  <purpose>
7
- After a SDD update wipes and reinstalls files, this command merges user's previously saved local modifications back into the new version. Uses intelligent comparison to handle cases where the upstream file also changed.
8
+ After a SDD update wipes and reinstalls files, this command merges user's previously saved local modifications back into the new version. Uses three-way comparison (pristine baseline, user-modified backup, newly installed version) to reliably distinguish user customizations from version drift.
9
+
10
+ **Critical invariant:** Every file in `sdd-local-patches/` was backed up because the installer's hash comparison detected it was modified. The workflow must NEVER conclude "no custom content" for any backed-up file — that is a logical contradiction. When in doubt, classify as CONFLICT requiring user review, not SKIP.
8
11
  </purpose>
9
12
 
10
13
  <process>
@@ -14,19 +17,90 @@ After a SDD update wipes and reinstalls files, this command merges user's previo
14
17
  Check for local patches directory:
15
18
 
16
19
  ```bash
17
- # Global install — detect runtime config directory
18
- if [ -d "$HOME/.config/opencode/sdd-local-patches" ]; then
19
- PATCHES_DIR="$HOME/.config/opencode/sdd-local-patches"
20
- elif [ -d "$HOME/.opencode/sdd-local-patches" ]; then
21
- PATCHES_DIR="$HOME/.opencode/sdd-local-patches"
22
- elif [ -d "$HOME/.gemini/sdd-local-patches" ]; then
23
- PATCHES_DIR="$HOME/.gemini/sdd-local-patches"
24
- else
25
- PATCHES_DIR="$HOME/.claude/sdd-local-patches"
20
+ expand_home() {
21
+ case "$1" in
22
+ "~/"*) printf '%s/%s\n' "$HOME" "${1#~/}" ;;
23
+ *) printf '%s\n' "$1" ;;
24
+ esac
25
+ }
26
+
27
+ PATCHES_DIR=""
28
+
29
+ # Env overrides first — covers custom config directories used with --config-dir
30
+ if [ -n "$KILO_CONFIG_DIR" ]; then
31
+ candidate="$(expand_home "$KILO_CONFIG_DIR")/sdd-local-patches"
32
+ if [ -d "$candidate" ]; then
33
+ PATCHES_DIR="$candidate"
34
+ fi
35
+ elif [ -n "$KILO_CONFIG" ]; then
36
+ candidate="$(dirname "$(expand_home "$KILO_CONFIG")")/sdd-local-patches"
37
+ if [ -d "$candidate" ]; then
38
+ PATCHES_DIR="$candidate"
39
+ fi
40
+ elif [ -n "$XDG_CONFIG_HOME" ]; then
41
+ candidate="$(expand_home "$XDG_CONFIG_HOME")/kilo/sdd-local-patches"
42
+ if [ -d "$candidate" ]; then
43
+ PATCHES_DIR="$candidate"
44
+ fi
45
+ fi
46
+
47
+ if [ -z "$PATCHES_DIR" ] && [ -n "$OPENCODE_CONFIG_DIR" ]; then
48
+ candidate="$(expand_home "$OPENCODE_CONFIG_DIR")/sdd-local-patches"
49
+ if [ -d "$candidate" ]; then
50
+ PATCHES_DIR="$candidate"
51
+ fi
52
+ elif [ -z "$PATCHES_DIR" ] && [ -n "$OPENCODE_CONFIG" ]; then
53
+ candidate="$(dirname "$(expand_home "$OPENCODE_CONFIG")")/sdd-local-patches"
54
+ if [ -d "$candidate" ]; then
55
+ PATCHES_DIR="$candidate"
56
+ fi
57
+ elif [ -z "$PATCHES_DIR" ] && [ -n "$XDG_CONFIG_HOME" ]; then
58
+ candidate="$(expand_home "$XDG_CONFIG_HOME")/opencode/sdd-local-patches"
59
+ if [ -d "$candidate" ]; then
60
+ PATCHES_DIR="$candidate"
61
+ fi
62
+ fi
63
+
64
+ if [ -z "$PATCHES_DIR" ] && [ -n "$GEMINI_CONFIG_DIR" ]; then
65
+ candidate="$(expand_home "$GEMINI_CONFIG_DIR")/sdd-local-patches"
66
+ if [ -d "$candidate" ]; then
67
+ PATCHES_DIR="$candidate"
68
+ fi
69
+ fi
70
+
71
+ if [ -z "$PATCHES_DIR" ] && [ -n "$CODEX_HOME" ]; then
72
+ candidate="$(expand_home "$CODEX_HOME")/sdd-local-patches"
73
+ if [ -d "$candidate" ]; then
74
+ PATCHES_DIR="$candidate"
75
+ fi
76
+ fi
77
+
78
+ if [ -z "$PATCHES_DIR" ] && [ -n "$CLAUDE_CONFIG_DIR" ]; then
79
+ candidate="$(expand_home "$CLAUDE_CONFIG_DIR")/sdd-local-patches"
80
+ if [ -d "$candidate" ]; then
81
+ PATCHES_DIR="$candidate"
82
+ fi
83
+ fi
84
+
85
+ # Global install — detect runtime config directory defaults
86
+ if [ -z "$PATCHES_DIR" ]; then
87
+ if [ -d "$HOME/.config/kilo/sdd-local-patches" ]; then
88
+ PATCHES_DIR="$HOME/.config/kilo/sdd-local-patches"
89
+ elif [ -d "$HOME/.config/opencode/sdd-local-patches" ]; then
90
+ PATCHES_DIR="$HOME/.config/opencode/sdd-local-patches"
91
+ elif [ -d "$HOME/.opencode/sdd-local-patches" ]; then
92
+ PATCHES_DIR="$HOME/.opencode/sdd-local-patches"
93
+ elif [ -d "$HOME/.gemini/sdd-local-patches" ]; then
94
+ PATCHES_DIR="$HOME/.gemini/sdd-local-patches"
95
+ elif [ -d "$HOME/.codex/sdd-local-patches" ]; then
96
+ PATCHES_DIR="$HOME/.codex/sdd-local-patches"
97
+ else
98
+ PATCHES_DIR="$HOME/.claude/sdd-local-patches"
99
+ fi
26
100
  fi
27
101
  # Local install fallback — check all runtime directories
28
102
  if [ ! -d "$PATCHES_DIR" ]; then
29
- for dir in .config/opencode .opencode .gemini .claude; do
103
+ for dir in .config/kilo .kilo .config/opencode .opencode .gemini .codex .claude; do
30
104
  if [ -d "./$dir/sdd-local-patches" ]; then
31
105
  PATCHES_DIR="./$dir/sdd-local-patches"
32
106
  break
@@ -41,12 +115,48 @@ Read `backup-meta.json` from the patches directory.
41
115
  ```
42
116
  No local patches found. Nothing to reapply.
43
117
 
44
- Local patches are automatically saved when you run /sdd:update
118
+ Local patches are automatically saved when you run /sdd-update
45
119
  after modifying any SDD workflow, command, or agent files.
46
120
  ```
47
121
  Exit.
48
122
 
49
- ## Step 2: Show patch summary
123
+ ## Step 2: Determine baseline for three-way comparison
124
+
125
+ The quality of the merge depends on having a **pristine baseline** — the original unmodified version of each file from the pre-update SDD release. This enables three-way comparison:
126
+ - **Pristine baseline** (original SDD file before any user edits)
127
+ - **User's version** (backed up in `sdd-local-patches/`)
128
+ - **New version** (freshly installed after update)
129
+
130
+ Check for baseline sources in priority order:
131
+
132
+ ### Option A: Git history (most reliable)
133
+ If the config directory is a git repository:
134
+ ```bash
135
+ CONFIG_DIR=$(dirname "$PATCHES_DIR")
136
+ if git -C "$CONFIG_DIR" rev-parse --git-dir >/dev/null 2>&1; then
137
+ HAS_GIT=true
138
+ fi
139
+ ```
140
+ When `HAS_GIT=true`, use `git log` to find the commit where SDD was originally installed (before user edits). For each file, the pristine baseline can be extracted with:
141
+ ```bash
142
+ git -C "$CONFIG_DIR" log --diff-filter=A --format="%H" -- "{file_path}"
143
+ ```
144
+ This gives the commit that first added the file (the install commit). Extract the pristine version:
145
+ ```bash
146
+ git -C "$CONFIG_DIR" show {install_commit}:{file_path}
147
+ ```
148
+
149
+ ### Option B: Pristine snapshot directory
150
+ Check if a `sdd-pristine/` directory exists alongside `sdd-local-patches/`:
151
+ ```bash
152
+ PRISTINE_DIR="$CONFIG_DIR/sdd-pristine"
153
+ ```
154
+ If it exists, the installer saved pristine copies at install time. Use these as the baseline.
155
+
156
+ ### Option C: No baseline available (two-way fallback)
157
+ If neither git history nor pristine snapshots are available, fall back to two-way comparison — but with **strengthened heuristics** (see Step 3).
158
+
159
+ ## Step 3: Show patch summary
50
160
 
51
161
  ```
52
162
  ## Local Patches to Reapply
@@ -54,6 +164,7 @@ Exit.
54
164
  **Backed up from:** v{from_version}
55
165
  **Current version:** {read VERSION file}
56
166
  **Files modified:** {count}
167
+ **Merge strategy:** {three-way (git) | three-way (pristine) | two-way (enhanced)}
57
168
 
58
169
  | # | File | Status |
59
170
  |---|------|--------|
@@ -61,54 +172,128 @@ Exit.
61
172
  | 2 | {file_path} | Pending |
62
173
  ```
63
174
 
64
- ## Step 3: Merge each file
175
+ ## Step 4: Merge each file
65
176
 
66
177
  For each file in `backup-meta.json`:
67
178
 
68
179
  1. **Read the backed-up version** (user's modified copy from `sdd-local-patches/`)
69
180
  2. **Read the newly installed version** (current file after update)
70
- 3. **Compare and merge:**
181
+ 3. **If available, read the pristine baseline** (from git history or `sdd-pristine/`)
71
182
 
72
- - If the new file is identical to the backed-up file: skip (modification was incorporated upstream)
73
- - If the new file differs: identify the user's modifications and apply them to the new version
183
+ ### Three-way merge (when baseline is available)
74
184
 
75
- **Merge strategy:**
76
- - Read both versions fully
77
- - Identify sections the user added or modified (look for additions, not just differences from path replacement)
78
- - Apply user's additions/modifications to the new version
79
- - If a section the user modified was also changed upstream: flag as conflict, show both versions, ask user which to keep
185
+ Compare the three versions to isolate changes:
186
+ - **User changes** = diff(pristine → user's version) — these are the customizations to preserve
187
+ - **Upstream changes** = diff(pristine new version) these are version updates to accept
80
188
 
81
- 4. **Write merged result** to the installed location
82
- 5. **Report status:**
83
- - `Merged` user modifications applied cleanly
84
- - `Skipped` modification already in upstream
85
- - `Conflict` user chose resolution
189
+ **Merge rules:**
190
+ - Sections changed only by user → apply user's version
191
+ - Sections changed only by upstream → accept upstream version
192
+ - Sections changed by both flag as CONFLICT, show both, ask user
193
+ - Sections unchanged by either → use new version (identical to all three)
86
194
 
87
- ## Step 4: Update manifest
195
+ ### Two-way merge (fallback when no baseline)
88
196
 
89
- After reapplying, regenerate the file manifest so future updates correctly detect these as user modifications:
197
+ When no pristine baseline is available, use these **strengthened heuristics**:
90
198
 
199
+ **CRITICAL RULE: Every file in this backup directory was explicitly detected as modified by the installer's SHA-256 hash comparison. "No custom content" is never a valid conclusion.**
200
+
201
+ For each file:
202
+ a. Read both versions completely
203
+ b. Identify ALL differences, then classify each as:
204
+ - **Mechanical drift** — path substitutions (e.g. `/Users/xxx/.claude/` → `$HOME/.claude/`), variable additions (`${SDD_WS}`, `${AGENT_SKILLS_*}`), error handling additions (`|| true`)
205
+ - **User customization** — added steps/sections, removed sections, reordered content, changed behavior, added frontmatter fields, modified instructions
206
+
207
+ c. **If ANY differences remain after filtering out mechanical drift → those are user customizations. Merge them.**
208
+ d. **If ALL differences appear to be mechanical drift → still flag as CONFLICT.** The installer's hash check already proved this file was modified. Ask the user: "This file appears to only have path/variable differences. Were there intentional customizations?" Do NOT silently skip.
209
+
210
+ ### Git-enhanced two-way merge
211
+
212
+ When the config directory is a git repo but the pristine install commit can't be found, use commit history to identify user changes:
91
213
  ```bash
92
- # The manifest will be regenerated on next /sdd:update
93
- # For now, just note which files were modified
214
+ # Find non-update commits that touched this file
215
+ git -C "$CONFIG_DIR" log --oneline --no-merges -- "{file_path}" | grep -v "sdd:update\|SDD update\|sdd-install"
216
+ ```
217
+ Each matching commit represents an intentional user modification. Use the commit messages and diffs to understand what was changed and why.
218
+
219
+ 4. **Write merged result** to the installed location
220
+
221
+ ### Post-merge verification
222
+
223
+ After writing each merged file, verify that user modifications survived the merge:
224
+
225
+ 1. **Line-count check:** Count lines in the backup and the merged result. If the merged result has fewer lines than the backup minus the expected upstream removals, flag for review.
226
+ 2. **Hunk presence check:** For each user-added section identified during diff analysis, search the merged output for at least the first significant line (non-blank, non-comment) of each addition. Missing signature lines indicate a dropped hunk.
227
+ 3. **Report warnings inline** (do not block):
228
+ ```
229
+ ⚠ Potential dropped content in {file_path}:
230
+ - Missing hunk near line {N}: "{first_line_preview}..." ({line_count} lines)
231
+ - Backup available: {patches_dir}/{file_path}
232
+ ```
233
+ 4. **Produce a Hunk Verification Table** — one row per hunk per file. This table is **mandatory output** and must be produced before Step 5 can proceed. Format:
234
+
235
+ | file | hunk_id | signature_line | line_count | verified |
236
+ |------|---------|----------------|------------|----------|
237
+ | {file_path} | {N} | {first_significant_line} | {count} | yes |
238
+ | {file_path} | {N} | {first_significant_line} | {count} | no |
239
+
240
+ - `hunk_id` — sequential integer per file (1, 2, 3…)
241
+ - `signature_line` — first non-blank, non-comment line of the user-added section
242
+ - `line_count` — total lines in the hunk
243
+ - `verified` — `yes` if the signature_line is present in the merged output, `no` otherwise
244
+
245
+ 5. **Track verification status** — add to per-file report: `Merged (verified)` vs `Merged (⚠ {N} hunks may be missing)`
246
+
247
+ 6. **Report status per file:**
248
+ - `Merged` — user modifications applied cleanly (show summary of what was preserved)
249
+ - `Conflict` — user reviewed and chose resolution
250
+ - `Incorporated` — user's modification was already adopted upstream (only valid when pristine baseline confirms this)
251
+
252
+ **Never report `Skipped — no custom content`.** If a file is in the backup, it has custom content.
253
+
254
+ ## Step 5: Hunk Verification Gate
255
+
256
+ Before proceeding to cleanup, evaluate the Hunk Verification Table produced in Step 4.
257
+
258
+ **If the Hunk Verification Table is absent** (Step 4 did not produce it), STOP immediately and report to the user:
259
+ ```
260
+ ERROR: Hunk Verification Table is missing. Post-merge verification was not completed.
261
+ Rerun /sdd-reapply-patches to retry with full verification.
262
+ ```
263
+
264
+ **If any row in the Hunk Verification Table shows `verified: no`**, STOP and report to the user:
94
265
  ```
266
+ ERROR: {N} hunk(s) failed verification — content may have been dropped during merge.
95
267
 
96
- ## Step 5: Cleanup option
268
+ Unverified hunks:
269
+ {file} hunk {hunk_id}: signature line "{signature_line}" not found in merged output
270
+
271
+ The backup is preserved at: {patches_dir}/{file}
272
+ Review the merged file manually, then either:
273
+ (a) Re-merge the missing content by hand, or
274
+ (b) Restore from backup: cp {patches_dir}/{file} {installed_path}
275
+ ```
276
+
277
+ Do not proceed to cleanup until the user confirms they have resolved all unverified hunks.
278
+
279
+ **Only when all rows show `verified: yes`** (or when all files had zero user-added hunks) may execution continue to Step 6.
280
+
281
+ ## Step 6: Cleanup option
97
282
 
98
283
  Ask user:
99
284
  - "Keep patch backups for reference?" → preserve `sdd-local-patches/`
100
285
  - "Clean up patch backups?" → remove `sdd-local-patches/` directory
101
286
 
102
- ## Step 6: Report
287
+ ## Step 7: Report
103
288
 
104
289
  ```
105
290
  ## Patches Reapplied
106
291
 
107
- | # | File | Status |
108
- |---|------|--------|
109
- | 1 | {file_path} | Merged |
110
- | 2 | {file_path} | Skipped (already upstream) |
111
- | 3 | {file_path} | Conflict resolved |
292
+ | # | File | Result | User Changes Preserved |
293
+ |---|------|--------|----------------------|
294
+ | 1 | {file_path} | Merged | Added step X, modified section Y |
295
+ | 2 | {file_path} | Incorporated | Already in upstream v{version} |
296
+ | 3 | {file_path} | Conflict resolved | User chose: keep custom section |
112
297
 
113
298
  {count} file(s) updated. Your local modifications are active again.
114
299
  ```
@@ -116,8 +301,11 @@ Ask user:
116
301
  </process>
117
302
 
118
303
  <success_criteria>
119
- - [ ] All backed-up patches processed
120
- - [ ] User modifications merged into new version
121
- - [ ] Conflicts resolved with user input
122
- - [ ] Status reported for each file
304
+ - [ ] All backed-up patches processed — zero files left unhandled
305
+ - [ ] No file classified as "no custom content" or "SKIP" — every backed-up file is definitionally modified
306
+ - [ ] Three-way merge used when pristine baseline available (git history or sdd-pristine/)
307
+ - [ ] User modifications identified and merged into new version
308
+ - [ ] Conflicts surfaced to user with both versions shown
309
+ - [ ] Status reported for each file with summary of what was preserved
310
+ - [ ] Post-merge verification checks each file for dropped hunks and warns if content appears missing
123
311
  </success_criteria>
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: sdd:research-phase
3
- description: Research how to implement a phase (standalone - usually use /sdd:plan-phase instead)
3
+ description: Research how to implement a phase (standalone - usually use /sdd-plan-phase instead)
4
4
  argument-hint: "[phase]"
5
5
  allowed-tools:
6
6
  - Read
@@ -11,7 +11,7 @@ allowed-tools:
11
11
  <objective>
12
12
  Research how to implement a phase. Spawns sdd-phase-researcher agent with phase context.
13
13
 
14
- **Note:** This is a standalone research command. For most workflows, use `/sdd:plan-phase` which integrates research automatically.
14
+ **Note:** This is a standalone research command. For most workflows, use `/sdd-plan-phase` which integrates research automatically.
15
15
 
16
16
  **Use this command when:**
17
17
  - You want to research without planning yet
@@ -115,7 +115,7 @@ Mode: ecosystem
115
115
  </additional_context>
116
116
 
117
117
  <downstream_consumer>
118
- Your RESEARCH.md will be loaded by `/sdd:plan-phase` which uses specific sections:
118
+ Your RESEARCH.md will be loaded by `/sdd-plan-phase` which uses specific sections:
119
119
  - `## Standard Stack` → Plans use these libraries
120
120
  - `## Architecture Patterns` → Task structure follows these
121
121
  - `## Don't Hand-Roll` → Tasks NEVER build custom solutions for listed problems
@@ -5,6 +5,7 @@ allowed-tools:
5
5
  - Read
6
6
  - Write
7
7
  - Bash
8
+ - AskUserQuestion
8
9
  ---
9
10
 
10
11
  <objective>
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: sdd:review
3
3
  description: Request cross-AI peer review of phase plans from external AI CLIs
4
- argument-hint: "--phase N [--gemini] [--claude] [--codex] [--all]"
4
+ argument-hint: "--phase N [--gemini] [--claude] [--codex] [--opencode] [--qwen] [--cursor] [--all]"
5
5
  allowed-tools:
6
6
  - Read
7
7
  - Write
@@ -11,9 +11,9 @@ allowed-tools:
11
11
  ---
12
12
 
13
13
  <objective>
14
- Invoke external AI CLIs (Gemini, Claude, Codex) to independently review phase plans.
14
+ Invoke external AI CLIs (Gemini, Claude, Codex, OpenCode, Qwen Code, Cursor) to independently review phase plans.
15
15
  Produces a structured REVIEWS.md with per-reviewer feedback that can be fed back into
16
- planning via /sdd:plan-phase --reviews.
16
+ planning via /sdd-plan-phase --reviews.
17
17
 
18
18
  **Flow:** Detect CLIs → Build review prompt → Invoke each CLI → Collect responses → Write REVIEWS.md
19
19
  </objective>
@@ -29,6 +29,9 @@ Phase number: extracted from $ARGUMENTS (required)
29
29
  - `--gemini` — Include Gemini CLI review
30
30
  - `--claude` — Include Claude CLI review (uses separate session)
31
31
  - `--codex` — Include Codex CLI review
32
+ - `--opencode` — Include OpenCode review (uses model from user's OpenCode config)
33
+ - `--qwen` — Include Qwen Code review (Alibaba Qwen models)
34
+ - `--cursor` — Include Cursor agent review
32
35
  - `--all` — Include all available CLIs
33
36
  </context>
34
37
 
@@ -0,0 +1,26 @@
1
+ ---
2
+ name: sdd:scan
3
+ description: Rapid codebase assessment — lightweight alternative to /sdd-map-codebase
4
+ allowed-tools:
5
+ - Read
6
+ - Write
7
+ - Bash
8
+ - Grep
9
+ - Glob
10
+ - Agent
11
+ - AskUserQuestion
12
+ ---
13
+ <objective>
14
+ Run a focused codebase scan for a single area, producing targeted documents in `.planning/codebase/`.
15
+ Accepts an optional `--focus` flag: `tech`, `arch`, `quality`, `concerns`, or `tech+arch` (default).
16
+
17
+ Lightweight alternative to `/sdd-map-codebase` — spawns one mapper agent instead of four parallel ones.
18
+ </objective>
19
+
20
+ <execution_context>
21
+ @~/.claude/sdd/workflows/scan.md
22
+ </execution_context>
23
+
24
+ <process>
25
+ Execute the scan workflow from @~/.claude/sdd/workflows/scan.md end-to-end.
26
+ </process>
@@ -0,0 +1,35 @@
1
+ ---
2
+ name: sdd:secure-phase
3
+ description: Retroactively verify threat mitigations for a completed phase
4
+ argument-hint: "[phase number]"
5
+ allowed-tools:
6
+ - Read
7
+ - Write
8
+ - Edit
9
+ - Bash
10
+ - Glob
11
+ - Grep
12
+ - Task
13
+ - AskUserQuestion
14
+ ---
15
+ <objective>
16
+ Verify threat mitigations for a completed phase. Three states:
17
+ - (A) SECURITY.md exists — audit and verify mitigations
18
+ - (B) No SECURITY.md, PLAN.md with threat model exists — run from artifacts
19
+ - (C) Phase not executed — exit with guidance
20
+
21
+ Output: updated SECURITY.md.
22
+ </objective>
23
+
24
+ <execution_context>
25
+ @~/.claude/sdd/workflows/secure-phase.md
26
+ </execution_context>
27
+
28
+ <context>
29
+ Phase: $ARGUMENTS — optional, defaults to last completed phase.
30
+ </context>
31
+
32
+ <process>
33
+ Execute @~/.claude/sdd/workflows/secure-phase.md.
34
+ Preserve all workflow gates.
35
+ </process>
@@ -11,7 +11,7 @@ allowed-tools:
11
11
  - AskUserQuestion
12
12
  ---
13
13
  <objective>
14
- Bridge local completion → merged PR. After /sdd:verify-work passes, ship the work: push branch, create PR with auto-generated body, optionally trigger review, and track the merge.
14
+ Bridge local completion → merged PR. After /sdd-verify-work passes, ship the work: push branch, create PR with auto-generated body, optionally trigger review, and track the merge.
15
15
 
16
16
  Closes the plan → execute → verify → ship loop.
17
17
  </objective>
@@ -39,7 +39,7 @@ For each thread, read the first few lines to show title and status:
39
39
 
40
40
  If no threads exist, show:
41
41
  ```
42
- No threads found. Create one with: /sdd:thread <description>
42
+ No threads found. Create one with: /sdd-thread <description>
43
43
  ```
44
44
  </mode_list>
45
45
 
@@ -62,7 +62,7 @@ Create a new thread:
62
62
 
63
63
  1. Generate slug from description:
64
64
  ```bash
65
- SLUG=$(node "$HOME/.claude/sdd/bin/sdd-tools.cjs" generate-slug "$ARGUMENTS")
65
+ SLUG=$(node "$HOME/.claude/sdd/bin/sdd-tools.cjs" generate-slug "$ARGUMENTS" --raw)
66
66
  ```
67
67
 
68
68
  2. Create the threads directory if needed:
@@ -111,7 +111,7 @@ Create a new thread:
111
111
  Thread: {slug}
112
112
  File: .planning/threads/{slug}.md
113
113
 
114
- Resume anytime with: /sdd:thread {slug}
114
+ Resume anytime with: /sdd-thread {slug}
115
115
  ```
116
116
  </mode_create>
117
117
 
@@ -119,9 +119,9 @@ Create a new thread:
119
119
 
120
120
  <notes>
121
121
  - Threads are NOT phase-scoped — they exist independently of the roadmap
122
- - Lighter weight than /sdd:pause-work — no phase state, no plan context
122
+ - Lighter weight than /sdd-pause-work — no phase state, no plan context
123
123
  - The value is in Context and Next Steps — a cold-start session can pick up immediately
124
124
  - Threads can be promoted to phases or backlog items when they mature:
125
- /sdd:add-phase or /sdd:add-backlog with context from the thread
125
+ /sdd-add-phase or /sdd-add-backlog with context from the thread
126
126
  - Thread files live in .planning/threads/ — no collision with phases or other SDD structures
127
127
  </notes>
@@ -0,0 +1,34 @@
1
+ ---
2
+ name: sdd:undo
3
+ description: "Safe git revert. Roll back phase or plan commits using the phase manifest with dependency checks."
4
+ argument-hint: "--last N | --phase NN | --plan NN-MM"
5
+ allowed-tools:
6
+ - Read
7
+ - Bash
8
+ - Glob
9
+ - Grep
10
+ - AskUserQuestion
11
+ ---
12
+
13
+ <objective>
14
+ Safe git revert — roll back SDD phase or plan commits using the phase manifest, with dependency checks and a confirmation gate before execution.
15
+
16
+ Three modes:
17
+ - **--last N**: Show recent SDD commits for interactive selection
18
+ - **--phase NN**: Revert all commits for a phase (manifest + git log fallback)
19
+ - **--plan NN-MM**: Revert all commits for a specific plan
20
+ </objective>
21
+
22
+ <execution_context>
23
+ @~/.claude/sdd/workflows/undo.md
24
+ @~/.claude/sdd/references/ui-brand.md
25
+ @~/.claude/sdd/references/gate-prompts.md
26
+ </execution_context>
27
+
28
+ <context>
29
+ $ARGUMENTS
30
+ </context>
31
+
32
+ <process>
33
+ Execute the undo workflow from @~/.claude/sdd/workflows/undo.md end-to-end.
34
+ </process>
@@ -16,7 +16,7 @@ Validate built features through conversational testing with persistent state.
16
16
 
17
17
  Purpose: Confirm what Claude built actually works from user's perspective. One test at a time, plain text responses, no interrogation. When issues are found, automatically diagnose, plan fixes, and prepare for execution.
18
18
 
19
- Output: {phase_num}-UAT.md tracking all test results. If issues found: diagnosed gaps, verified fix plans ready for /sdd:execute-phase
19
+ Output: {phase_num}-UAT.md tracking all test results. If issues found: diagnosed gaps, verified fix plans ready for /sdd-execute-phase
20
20
  </objective>
21
21
 
22
22
  <execution_context>
@@ -1,14 +1,18 @@
1
1
  ---
2
+ name: sdd:workstreams
2
3
  description: Manage parallel workstreams — list, create, switch, status, progress, complete, and resume
4
+ allowed-tools:
5
+ - Read
6
+ - Bash
3
7
  ---
4
8
 
5
- # /sdd:workstreams
9
+ # /sdd-workstreams
6
10
 
7
11
  Manage parallel workstreams for concurrent milestone work.
8
12
 
9
13
  ## Usage
10
14
 
11
- `/sdd:workstreams [subcommand] [args]`
15
+ `/sdd-workstreams [subcommand] [args]`
12
16
 
13
17
  ### Subcommands
14
18
 
@@ -30,32 +34,34 @@ If no subcommand given, default to `list`.
30
34
  ## Step 2: Execute Operation
31
35
 
32
36
  ### list
33
- Run: `node "$SDD_TOOLS" workstream list --raw --cwd "$CWD"`
37
+ Run: `node "$HOME/.claude/sdd/bin/sdd-tools.cjs" workstream list --raw --cwd "$CWD"`
34
38
  Display the workstreams in a table format showing name, status, current phase, and progress.
35
39
 
36
40
  ### create
37
- Run: `node "$SDD_TOOLS" workstream create <name> --raw --cwd "$CWD"`
41
+ Run: `node "$HOME/.claude/sdd/bin/sdd-tools.cjs" workstream create <name> --raw --cwd "$CWD"`
38
42
  After creation, display the new workstream path and suggest next steps:
39
- - `/sdd:new-milestone --ws <name>` to set up the milestone
43
+ - `/sdd-new-milestone --ws <name>` to set up the milestone
40
44
 
41
45
  ### status
42
- Run: `node "$SDD_TOOLS" workstream status <name> --raw --cwd "$CWD"`
46
+ Run: `node "$HOME/.claude/sdd/bin/sdd-tools.cjs" workstream status <name> --raw --cwd "$CWD"`
43
47
  Display detailed phase breakdown and state information.
44
48
 
45
49
  ### switch
46
- Run: `node "$SDD_TOOLS" workstream set <name> --raw --cwd "$CWD"`
47
- Also set `SDD_WORKSTREAM` env var for the current session.
50
+ Run: `node "$HOME/.claude/sdd/bin/sdd-tools.cjs" workstream set <name> --raw --cwd "$CWD"`
51
+ Also set `SDD_WORKSTREAM` for the current session when the runtime supports it.
52
+ If the runtime exposes a session identifier, SDD also stores the active workstream
53
+ session-locally so concurrent sessions do not overwrite each other.
48
54
 
49
55
  ### progress
50
- Run: `node "$SDD_TOOLS" workstream progress --raw --cwd "$CWD"`
56
+ Run: `node "$HOME/.claude/sdd/bin/sdd-tools.cjs" workstream progress --raw --cwd "$CWD"`
51
57
  Display a progress overview across all workstreams.
52
58
 
53
59
  ### complete
54
- Run: `node "$SDD_TOOLS" workstream complete <name> --raw --cwd "$CWD"`
60
+ Run: `node "$HOME/.claude/sdd/bin/sdd-tools.cjs" workstream complete <name> --raw --cwd "$CWD"`
55
61
  Archive the workstream to milestones/.
56
62
 
57
63
  ### resume
58
- Set the workstream as active and suggest `/sdd:resume-work --ws <name>`.
64
+ Set the workstream as active and suggest `/sdd-resume-work --ws <name>`.
59
65
 
60
66
  ## Step 3: Display Results
61
67