mustflow 1.18.16 → 1.30.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 (303) hide show
  1. package/README.md +16 -6
  2. package/dist/cli/commands/adapters.js +90 -0
  3. package/dist/cli/commands/classify.js +3 -4
  4. package/dist/cli/commands/contract-lint.js +26 -6
  5. package/dist/cli/commands/dashboard.js +103 -4
  6. package/dist/cli/commands/explain-verify.js +213 -0
  7. package/dist/cli/commands/explain.js +48 -4
  8. package/dist/cli/commands/handoff.js +136 -0
  9. package/dist/cli/commands/run.js +97 -136
  10. package/dist/cli/commands/update.js +91 -61
  11. package/dist/cli/commands/verify.js +230 -137
  12. package/dist/cli/i18n/en.js +65 -4
  13. package/dist/cli/i18n/es.js +65 -4
  14. package/dist/cli/i18n/fr.js +65 -4
  15. package/dist/cli/i18n/hi.js +65 -4
  16. package/dist/cli/i18n/ko.js +65 -4
  17. package/dist/cli/i18n/zh.js +65 -4
  18. package/dist/cli/index.js +11 -0
  19. package/dist/cli/lib/command-registry.js +10 -0
  20. package/dist/cli/lib/dashboard-export.js +775 -0
  21. package/dist/cli/lib/local-index.js +22 -6
  22. package/dist/cli/lib/run-plan.js +222 -0
  23. package/dist/cli/lib/templates.js +18 -3
  24. package/dist/cli/lib/update-diff-preview.js +163 -0
  25. package/dist/cli/lib/validation.js +22 -0
  26. package/dist/core/adapter-compatibility.js +235 -0
  27. package/dist/core/change-classification.js +9 -0
  28. package/dist/core/change-verification.js +10 -3
  29. package/dist/core/check-issues.js +4 -0
  30. package/dist/core/command-contract-validation.js +14 -0
  31. package/dist/core/command-cwd.js +18 -6
  32. package/dist/core/command-env.js +91 -0
  33. package/dist/core/contract-lint.js +165 -3
  34. package/dist/core/contract-models.js +172 -0
  35. package/dist/core/dashboard-verification.js +2 -0
  36. package/dist/core/doc-review-triage.js +1 -0
  37. package/dist/core/handoff-record.js +376 -0
  38. package/dist/core/public-json-contracts.js +16 -0
  39. package/dist/core/run-receipt.js +46 -7
  40. package/dist/core/run-write-drift.js +180 -0
  41. package/dist/core/secret-redaction.js +39 -0
  42. package/dist/core/source-anchors.js +3 -5
  43. package/dist/core/verification-decision-graph.js +223 -0
  44. package/package.json +3 -1
  45. package/schemas/README.md +11 -4
  46. package/schemas/adapter-compatibility-report.schema.json +184 -0
  47. package/schemas/change-verification-report.schema.json +133 -1
  48. package/schemas/commands.schema.json +8 -1
  49. package/schemas/contract-lint-report.schema.json +48 -0
  50. package/schemas/explain-report.schema.json +265 -2
  51. package/schemas/handoff-validation-report.schema.json +68 -0
  52. package/schemas/run-receipt.schema.json +74 -1
  53. package/templates/default/common/.mustflow/config/commands.toml +2 -0
  54. package/templates/default/i18n.toml +78 -234
  55. package/templates/default/locales/en/.mustflow/skills/INDEX.md +7 -3
  56. package/templates/default/locales/en/.mustflow/skills/architecture-deepening-review/SKILL.md +154 -0
  57. package/templates/default/locales/en/.mustflow/skills/behavior-preserving-refactor/SKILL.md +8 -3
  58. package/templates/default/locales/en/.mustflow/skills/code-review/SKILL.md +9 -4
  59. package/templates/default/locales/en/.mustflow/skills/date-number-audit/SKILL.md +19 -4
  60. package/templates/default/locales/en/.mustflow/skills/diff-risk-review/SKILL.md +4 -2
  61. package/templates/default/locales/en/.mustflow/skills/external-skill-intake/SKILL.md +141 -0
  62. package/templates/default/locales/en/.mustflow/skills/release-notes-authoring/SKILL.md +143 -0
  63. package/templates/default/locales/en/.mustflow/skills/repro-first-debug/SKILL.md +22 -8
  64. package/templates/default/locales/en/.mustflow/skills/skill-authoring/SKILL.md +3 -3
  65. package/templates/default/locales/en/.mustflow/skills/source-freshness-check/SKILL.md +22 -9
  66. package/templates/default/locales/en/.mustflow/skills/ui-quality-gate/SKILL.md +21 -13
  67. package/templates/default/locales/en/.mustflow/skills/vertical-slice-tdd/SKILL.md +167 -0
  68. package/templates/default/manifest.toml +16 -1
  69. package/templates/default/locales/es/.mustflow/skills/INDEX.md +0 -75
  70. package/templates/default/locales/es/.mustflow/skills/adapter-boundary/SKILL.md +0 -193
  71. package/templates/default/locales/es/.mustflow/skills/artifact-integrity-check/SKILL.md +0 -114
  72. package/templates/default/locales/es/.mustflow/skills/behavior-preserving-refactor/SKILL.md +0 -182
  73. package/templates/default/locales/es/.mustflow/skills/code-review/SKILL.md +0 -115
  74. package/templates/default/locales/es/.mustflow/skills/codebase-orientation/SKILL.md +0 -115
  75. package/templates/default/locales/es/.mustflow/skills/command-pattern/SKILL.md +0 -247
  76. package/templates/default/locales/es/.mustflow/skills/composition-over-inheritance/SKILL.md +0 -176
  77. package/templates/default/locales/es/.mustflow/skills/contract-sync-check/SKILL.md +0 -116
  78. package/templates/default/locales/es/.mustflow/skills/database-change-safety/SKILL.md +0 -155
  79. package/templates/default/locales/es/.mustflow/skills/date-number-audit/SKILL.md +0 -116
  80. package/templates/default/locales/es/.mustflow/skills/dependency-injection/SKILL.md +0 -161
  81. package/templates/default/locales/es/.mustflow/skills/dependency-reality-check/SKILL.md +0 -115
  82. package/templates/default/locales/es/.mustflow/skills/diff-risk-review/SKILL.md +0 -136
  83. package/templates/default/locales/es/.mustflow/skills/docs-prose-review/SKILL.md +0 -119
  84. package/templates/default/locales/es/.mustflow/skills/docs-update/SKILL.md +0 -97
  85. package/templates/default/locales/es/.mustflow/skills/external-prompt-injection-defense/SKILL.md +0 -116
  86. package/templates/default/locales/es/.mustflow/skills/facade-pattern/SKILL.md +0 -210
  87. package/templates/default/locales/es/.mustflow/skills/failure-triage/SKILL.md +0 -97
  88. package/templates/default/locales/es/.mustflow/skills/instruction-conflict-scope-check/SKILL.md +0 -118
  89. package/templates/default/locales/es/.mustflow/skills/line-ending-hygiene/SKILL.md +0 -111
  90. package/templates/default/locales/es/.mustflow/skills/migration-safety-check/SKILL.md +0 -117
  91. package/templates/default/locales/es/.mustflow/skills/multi-agent-work-coordination/SKILL.md +0 -260
  92. package/templates/default/locales/es/.mustflow/skills/null-object-pattern/SKILL.md +0 -196
  93. package/templates/default/locales/es/.mustflow/skills/pattern-scout/SKILL.md +0 -110
  94. package/templates/default/locales/es/.mustflow/skills/performance-budget-check/SKILL.md +0 -121
  95. package/templates/default/locales/es/.mustflow/skills/project-context-authoring/SKILL.md +0 -107
  96. package/templates/default/locales/es/.mustflow/skills/pure-core-imperative-shell/SKILL.md +0 -212
  97. package/templates/default/locales/es/.mustflow/skills/readme-authoring/SKILL.md +0 -115
  98. package/templates/default/locales/es/.mustflow/skills/repo-improvement-loop/SKILL.md +0 -150
  99. package/templates/default/locales/es/.mustflow/skills/repro-first-debug/SKILL.md +0 -112
  100. package/templates/default/locales/es/.mustflow/skills/requirement-regression-guard/SKILL.md +0 -152
  101. package/templates/default/locales/es/.mustflow/skills/result-option/SKILL.md +0 -186
  102. package/templates/default/locales/es/.mustflow/skills/security-privacy-review/SKILL.md +0 -116
  103. package/templates/default/locales/es/.mustflow/skills/security-regression-tests/SKILL.md +0 -131
  104. package/templates/default/locales/es/.mustflow/skills/skill-authoring/SKILL.md +0 -110
  105. package/templates/default/locales/es/.mustflow/skills/source-freshness-check/SKILL.md +0 -111
  106. package/templates/default/locales/es/.mustflow/skills/state-machine-pattern/SKILL.md +0 -214
  107. package/templates/default/locales/es/.mustflow/skills/strategy-pattern/SKILL.md +0 -215
  108. package/templates/default/locales/es/.mustflow/skills/structure-discovery-gate/SKILL.md +0 -159
  109. package/templates/default/locales/es/.mustflow/skills/test-design-guard/SKILL.md +0 -162
  110. package/templates/default/locales/es/.mustflow/skills/test-maintenance/SKILL.md +0 -122
  111. package/templates/default/locales/es/.mustflow/skills/ui-quality-gate/SKILL.md +0 -117
  112. package/templates/default/locales/es/.mustflow/skills/visual-review-artifact/SKILL.md +0 -127
  113. package/templates/default/locales/es/.mustflow/skills/visual-review-artifact/assets/review-template.html +0 -286
  114. package/templates/default/locales/es/.mustflow/skills/visual-review-artifact/resources.toml +0 -7
  115. package/templates/default/locales/es/.mustflow/skills/web-asset-optimization/SKILL.md +0 -108
  116. package/templates/default/locales/fr/.mustflow/skills/INDEX.md +0 -75
  117. package/templates/default/locales/fr/.mustflow/skills/adapter-boundary/SKILL.md +0 -193
  118. package/templates/default/locales/fr/.mustflow/skills/artifact-integrity-check/SKILL.md +0 -114
  119. package/templates/default/locales/fr/.mustflow/skills/behavior-preserving-refactor/SKILL.md +0 -182
  120. package/templates/default/locales/fr/.mustflow/skills/code-review/SKILL.md +0 -115
  121. package/templates/default/locales/fr/.mustflow/skills/codebase-orientation/SKILL.md +0 -115
  122. package/templates/default/locales/fr/.mustflow/skills/command-pattern/SKILL.md +0 -247
  123. package/templates/default/locales/fr/.mustflow/skills/composition-over-inheritance/SKILL.md +0 -176
  124. package/templates/default/locales/fr/.mustflow/skills/contract-sync-check/SKILL.md +0 -116
  125. package/templates/default/locales/fr/.mustflow/skills/database-change-safety/SKILL.md +0 -155
  126. package/templates/default/locales/fr/.mustflow/skills/date-number-audit/SKILL.md +0 -116
  127. package/templates/default/locales/fr/.mustflow/skills/dependency-injection/SKILL.md +0 -161
  128. package/templates/default/locales/fr/.mustflow/skills/dependency-reality-check/SKILL.md +0 -115
  129. package/templates/default/locales/fr/.mustflow/skills/diff-risk-review/SKILL.md +0 -136
  130. package/templates/default/locales/fr/.mustflow/skills/docs-prose-review/SKILL.md +0 -119
  131. package/templates/default/locales/fr/.mustflow/skills/docs-update/SKILL.md +0 -97
  132. package/templates/default/locales/fr/.mustflow/skills/external-prompt-injection-defense/SKILL.md +0 -116
  133. package/templates/default/locales/fr/.mustflow/skills/facade-pattern/SKILL.md +0 -210
  134. package/templates/default/locales/fr/.mustflow/skills/failure-triage/SKILL.md +0 -97
  135. package/templates/default/locales/fr/.mustflow/skills/instruction-conflict-scope-check/SKILL.md +0 -118
  136. package/templates/default/locales/fr/.mustflow/skills/line-ending-hygiene/SKILL.md +0 -111
  137. package/templates/default/locales/fr/.mustflow/skills/migration-safety-check/SKILL.md +0 -117
  138. package/templates/default/locales/fr/.mustflow/skills/multi-agent-work-coordination/SKILL.md +0 -260
  139. package/templates/default/locales/fr/.mustflow/skills/null-object-pattern/SKILL.md +0 -196
  140. package/templates/default/locales/fr/.mustflow/skills/pattern-scout/SKILL.md +0 -110
  141. package/templates/default/locales/fr/.mustflow/skills/performance-budget-check/SKILL.md +0 -121
  142. package/templates/default/locales/fr/.mustflow/skills/project-context-authoring/SKILL.md +0 -107
  143. package/templates/default/locales/fr/.mustflow/skills/pure-core-imperative-shell/SKILL.md +0 -212
  144. package/templates/default/locales/fr/.mustflow/skills/readme-authoring/SKILL.md +0 -115
  145. package/templates/default/locales/fr/.mustflow/skills/repo-improvement-loop/SKILL.md +0 -150
  146. package/templates/default/locales/fr/.mustflow/skills/repro-first-debug/SKILL.md +0 -112
  147. package/templates/default/locales/fr/.mustflow/skills/requirement-regression-guard/SKILL.md +0 -152
  148. package/templates/default/locales/fr/.mustflow/skills/result-option/SKILL.md +0 -186
  149. package/templates/default/locales/fr/.mustflow/skills/security-privacy-review/SKILL.md +0 -116
  150. package/templates/default/locales/fr/.mustflow/skills/security-regression-tests/SKILL.md +0 -131
  151. package/templates/default/locales/fr/.mustflow/skills/skill-authoring/SKILL.md +0 -110
  152. package/templates/default/locales/fr/.mustflow/skills/source-freshness-check/SKILL.md +0 -111
  153. package/templates/default/locales/fr/.mustflow/skills/state-machine-pattern/SKILL.md +0 -214
  154. package/templates/default/locales/fr/.mustflow/skills/strategy-pattern/SKILL.md +0 -215
  155. package/templates/default/locales/fr/.mustflow/skills/structure-discovery-gate/SKILL.md +0 -159
  156. package/templates/default/locales/fr/.mustflow/skills/test-design-guard/SKILL.md +0 -162
  157. package/templates/default/locales/fr/.mustflow/skills/test-maintenance/SKILL.md +0 -122
  158. package/templates/default/locales/fr/.mustflow/skills/ui-quality-gate/SKILL.md +0 -117
  159. package/templates/default/locales/fr/.mustflow/skills/visual-review-artifact/SKILL.md +0 -127
  160. package/templates/default/locales/fr/.mustflow/skills/visual-review-artifact/assets/review-template.html +0 -286
  161. package/templates/default/locales/fr/.mustflow/skills/visual-review-artifact/resources.toml +0 -7
  162. package/templates/default/locales/fr/.mustflow/skills/web-asset-optimization/SKILL.md +0 -108
  163. package/templates/default/locales/hi/.mustflow/skills/INDEX.md +0 -75
  164. package/templates/default/locales/hi/.mustflow/skills/adapter-boundary/SKILL.md +0 -193
  165. package/templates/default/locales/hi/.mustflow/skills/artifact-integrity-check/SKILL.md +0 -114
  166. package/templates/default/locales/hi/.mustflow/skills/behavior-preserving-refactor/SKILL.md +0 -182
  167. package/templates/default/locales/hi/.mustflow/skills/code-review/SKILL.md +0 -115
  168. package/templates/default/locales/hi/.mustflow/skills/codebase-orientation/SKILL.md +0 -115
  169. package/templates/default/locales/hi/.mustflow/skills/command-pattern/SKILL.md +0 -247
  170. package/templates/default/locales/hi/.mustflow/skills/composition-over-inheritance/SKILL.md +0 -176
  171. package/templates/default/locales/hi/.mustflow/skills/contract-sync-check/SKILL.md +0 -116
  172. package/templates/default/locales/hi/.mustflow/skills/database-change-safety/SKILL.md +0 -155
  173. package/templates/default/locales/hi/.mustflow/skills/date-number-audit/SKILL.md +0 -116
  174. package/templates/default/locales/hi/.mustflow/skills/dependency-injection/SKILL.md +0 -161
  175. package/templates/default/locales/hi/.mustflow/skills/dependency-reality-check/SKILL.md +0 -115
  176. package/templates/default/locales/hi/.mustflow/skills/diff-risk-review/SKILL.md +0 -136
  177. package/templates/default/locales/hi/.mustflow/skills/docs-prose-review/SKILL.md +0 -119
  178. package/templates/default/locales/hi/.mustflow/skills/docs-update/SKILL.md +0 -97
  179. package/templates/default/locales/hi/.mustflow/skills/external-prompt-injection-defense/SKILL.md +0 -116
  180. package/templates/default/locales/hi/.mustflow/skills/facade-pattern/SKILL.md +0 -210
  181. package/templates/default/locales/hi/.mustflow/skills/failure-triage/SKILL.md +0 -97
  182. package/templates/default/locales/hi/.mustflow/skills/instruction-conflict-scope-check/SKILL.md +0 -118
  183. package/templates/default/locales/hi/.mustflow/skills/line-ending-hygiene/SKILL.md +0 -111
  184. package/templates/default/locales/hi/.mustflow/skills/migration-safety-check/SKILL.md +0 -117
  185. package/templates/default/locales/hi/.mustflow/skills/multi-agent-work-coordination/SKILL.md +0 -260
  186. package/templates/default/locales/hi/.mustflow/skills/null-object-pattern/SKILL.md +0 -196
  187. package/templates/default/locales/hi/.mustflow/skills/pattern-scout/SKILL.md +0 -110
  188. package/templates/default/locales/hi/.mustflow/skills/performance-budget-check/SKILL.md +0 -121
  189. package/templates/default/locales/hi/.mustflow/skills/project-context-authoring/SKILL.md +0 -107
  190. package/templates/default/locales/hi/.mustflow/skills/pure-core-imperative-shell/SKILL.md +0 -212
  191. package/templates/default/locales/hi/.mustflow/skills/readme-authoring/SKILL.md +0 -115
  192. package/templates/default/locales/hi/.mustflow/skills/repo-improvement-loop/SKILL.md +0 -150
  193. package/templates/default/locales/hi/.mustflow/skills/repro-first-debug/SKILL.md +0 -112
  194. package/templates/default/locales/hi/.mustflow/skills/requirement-regression-guard/SKILL.md +0 -152
  195. package/templates/default/locales/hi/.mustflow/skills/result-option/SKILL.md +0 -186
  196. package/templates/default/locales/hi/.mustflow/skills/security-privacy-review/SKILL.md +0 -116
  197. package/templates/default/locales/hi/.mustflow/skills/security-regression-tests/SKILL.md +0 -131
  198. package/templates/default/locales/hi/.mustflow/skills/skill-authoring/SKILL.md +0 -110
  199. package/templates/default/locales/hi/.mustflow/skills/source-freshness-check/SKILL.md +0 -111
  200. package/templates/default/locales/hi/.mustflow/skills/state-machine-pattern/SKILL.md +0 -214
  201. package/templates/default/locales/hi/.mustflow/skills/strategy-pattern/SKILL.md +0 -215
  202. package/templates/default/locales/hi/.mustflow/skills/structure-discovery-gate/SKILL.md +0 -159
  203. package/templates/default/locales/hi/.mustflow/skills/test-design-guard/SKILL.md +0 -162
  204. package/templates/default/locales/hi/.mustflow/skills/test-maintenance/SKILL.md +0 -122
  205. package/templates/default/locales/hi/.mustflow/skills/ui-quality-gate/SKILL.md +0 -117
  206. package/templates/default/locales/hi/.mustflow/skills/visual-review-artifact/SKILL.md +0 -127
  207. package/templates/default/locales/hi/.mustflow/skills/visual-review-artifact/assets/review-template.html +0 -286
  208. package/templates/default/locales/hi/.mustflow/skills/visual-review-artifact/resources.toml +0 -7
  209. package/templates/default/locales/hi/.mustflow/skills/web-asset-optimization/SKILL.md +0 -108
  210. package/templates/default/locales/ko/.mustflow/skills/INDEX.md +0 -80
  211. package/templates/default/locales/ko/.mustflow/skills/adapter-boundary/SKILL.md +0 -193
  212. package/templates/default/locales/ko/.mustflow/skills/artifact-integrity-check/SKILL.md +0 -114
  213. package/templates/default/locales/ko/.mustflow/skills/behavior-preserving-refactor/SKILL.md +0 -182
  214. package/templates/default/locales/ko/.mustflow/skills/code-review/SKILL.md +0 -118
  215. package/templates/default/locales/ko/.mustflow/skills/codebase-orientation/SKILL.md +0 -115
  216. package/templates/default/locales/ko/.mustflow/skills/command-pattern/SKILL.md +0 -247
  217. package/templates/default/locales/ko/.mustflow/skills/composition-over-inheritance/SKILL.md +0 -176
  218. package/templates/default/locales/ko/.mustflow/skills/contract-sync-check/SKILL.md +0 -116
  219. package/templates/default/locales/ko/.mustflow/skills/database-change-safety/SKILL.md +0 -155
  220. package/templates/default/locales/ko/.mustflow/skills/date-number-audit/SKILL.md +0 -116
  221. package/templates/default/locales/ko/.mustflow/skills/dependency-injection/SKILL.md +0 -161
  222. package/templates/default/locales/ko/.mustflow/skills/dependency-reality-check/SKILL.md +0 -115
  223. package/templates/default/locales/ko/.mustflow/skills/diff-risk-review/SKILL.md +0 -136
  224. package/templates/default/locales/ko/.mustflow/skills/docs-prose-review/SKILL.md +0 -119
  225. package/templates/default/locales/ko/.mustflow/skills/docs-update/SKILL.md +0 -107
  226. package/templates/default/locales/ko/.mustflow/skills/external-prompt-injection-defense/SKILL.md +0 -116
  227. package/templates/default/locales/ko/.mustflow/skills/facade-pattern/SKILL.md +0 -210
  228. package/templates/default/locales/ko/.mustflow/skills/failure-triage/SKILL.md +0 -119
  229. package/templates/default/locales/ko/.mustflow/skills/instruction-conflict-scope-check/SKILL.md +0 -118
  230. package/templates/default/locales/ko/.mustflow/skills/line-ending-hygiene/SKILL.md +0 -111
  231. package/templates/default/locales/ko/.mustflow/skills/migration-safety-check/SKILL.md +0 -117
  232. package/templates/default/locales/ko/.mustflow/skills/multi-agent-work-coordination/SKILL.md +0 -259
  233. package/templates/default/locales/ko/.mustflow/skills/null-object-pattern/SKILL.md +0 -196
  234. package/templates/default/locales/ko/.mustflow/skills/pattern-scout/SKILL.md +0 -110
  235. package/templates/default/locales/ko/.mustflow/skills/performance-budget-check/SKILL.md +0 -121
  236. package/templates/default/locales/ko/.mustflow/skills/project-context-authoring/SKILL.md +0 -107
  237. package/templates/default/locales/ko/.mustflow/skills/pure-core-imperative-shell/SKILL.md +0 -212
  238. package/templates/default/locales/ko/.mustflow/skills/readme-authoring/SKILL.md +0 -115
  239. package/templates/default/locales/ko/.mustflow/skills/repo-improvement-loop/SKILL.md +0 -150
  240. package/templates/default/locales/ko/.mustflow/skills/repro-first-debug/SKILL.md +0 -112
  241. package/templates/default/locales/ko/.mustflow/skills/requirement-regression-guard/SKILL.md +0 -152
  242. package/templates/default/locales/ko/.mustflow/skills/result-option/SKILL.md +0 -186
  243. package/templates/default/locales/ko/.mustflow/skills/security-privacy-review/SKILL.md +0 -116
  244. package/templates/default/locales/ko/.mustflow/skills/security-regression-tests/SKILL.md +0 -131
  245. package/templates/default/locales/ko/.mustflow/skills/skill-authoring/SKILL.md +0 -110
  246. package/templates/default/locales/ko/.mustflow/skills/source-freshness-check/SKILL.md +0 -111
  247. package/templates/default/locales/ko/.mustflow/skills/state-machine-pattern/SKILL.md +0 -214
  248. package/templates/default/locales/ko/.mustflow/skills/strategy-pattern/SKILL.md +0 -215
  249. package/templates/default/locales/ko/.mustflow/skills/structure-discovery-gate/SKILL.md +0 -159
  250. package/templates/default/locales/ko/.mustflow/skills/test-design-guard/SKILL.md +0 -162
  251. package/templates/default/locales/ko/.mustflow/skills/test-maintenance/SKILL.md +0 -130
  252. package/templates/default/locales/ko/.mustflow/skills/ui-quality-gate/SKILL.md +0 -117
  253. package/templates/default/locales/ko/.mustflow/skills/visual-review-artifact/SKILL.md +0 -127
  254. package/templates/default/locales/ko/.mustflow/skills/visual-review-artifact/assets/review-template.html +0 -286
  255. package/templates/default/locales/ko/.mustflow/skills/visual-review-artifact/resources.toml +0 -7
  256. package/templates/default/locales/ko/.mustflow/skills/web-asset-optimization/SKILL.md +0 -108
  257. package/templates/default/locales/zh/.mustflow/skills/INDEX.md +0 -74
  258. package/templates/default/locales/zh/.mustflow/skills/adapter-boundary/SKILL.md +0 -193
  259. package/templates/default/locales/zh/.mustflow/skills/artifact-integrity-check/SKILL.md +0 -114
  260. package/templates/default/locales/zh/.mustflow/skills/behavior-preserving-refactor/SKILL.md +0 -182
  261. package/templates/default/locales/zh/.mustflow/skills/code-review/SKILL.md +0 -115
  262. package/templates/default/locales/zh/.mustflow/skills/codebase-orientation/SKILL.md +0 -115
  263. package/templates/default/locales/zh/.mustflow/skills/command-pattern/SKILL.md +0 -247
  264. package/templates/default/locales/zh/.mustflow/skills/composition-over-inheritance/SKILL.md +0 -176
  265. package/templates/default/locales/zh/.mustflow/skills/contract-sync-check/SKILL.md +0 -116
  266. package/templates/default/locales/zh/.mustflow/skills/database-change-safety/SKILL.md +0 -155
  267. package/templates/default/locales/zh/.mustflow/skills/date-number-audit/SKILL.md +0 -116
  268. package/templates/default/locales/zh/.mustflow/skills/dependency-injection/SKILL.md +0 -161
  269. package/templates/default/locales/zh/.mustflow/skills/dependency-reality-check/SKILL.md +0 -115
  270. package/templates/default/locales/zh/.mustflow/skills/diff-risk-review/SKILL.md +0 -136
  271. package/templates/default/locales/zh/.mustflow/skills/docs-prose-review/SKILL.md +0 -119
  272. package/templates/default/locales/zh/.mustflow/skills/docs-update/SKILL.md +0 -97
  273. package/templates/default/locales/zh/.mustflow/skills/external-prompt-injection-defense/SKILL.md +0 -116
  274. package/templates/default/locales/zh/.mustflow/skills/facade-pattern/SKILL.md +0 -210
  275. package/templates/default/locales/zh/.mustflow/skills/failure-triage/SKILL.md +0 -96
  276. package/templates/default/locales/zh/.mustflow/skills/instruction-conflict-scope-check/SKILL.md +0 -118
  277. package/templates/default/locales/zh/.mustflow/skills/line-ending-hygiene/SKILL.md +0 -111
  278. package/templates/default/locales/zh/.mustflow/skills/migration-safety-check/SKILL.md +0 -117
  279. package/templates/default/locales/zh/.mustflow/skills/multi-agent-work-coordination/SKILL.md +0 -260
  280. package/templates/default/locales/zh/.mustflow/skills/null-object-pattern/SKILL.md +0 -196
  281. package/templates/default/locales/zh/.mustflow/skills/pattern-scout/SKILL.md +0 -110
  282. package/templates/default/locales/zh/.mustflow/skills/performance-budget-check/SKILL.md +0 -121
  283. package/templates/default/locales/zh/.mustflow/skills/project-context-authoring/SKILL.md +0 -107
  284. package/templates/default/locales/zh/.mustflow/skills/pure-core-imperative-shell/SKILL.md +0 -212
  285. package/templates/default/locales/zh/.mustflow/skills/readme-authoring/SKILL.md +0 -115
  286. package/templates/default/locales/zh/.mustflow/skills/repo-improvement-loop/SKILL.md +0 -150
  287. package/templates/default/locales/zh/.mustflow/skills/repro-first-debug/SKILL.md +0 -112
  288. package/templates/default/locales/zh/.mustflow/skills/requirement-regression-guard/SKILL.md +0 -152
  289. package/templates/default/locales/zh/.mustflow/skills/result-option/SKILL.md +0 -186
  290. package/templates/default/locales/zh/.mustflow/skills/security-privacy-review/SKILL.md +0 -116
  291. package/templates/default/locales/zh/.mustflow/skills/security-regression-tests/SKILL.md +0 -131
  292. package/templates/default/locales/zh/.mustflow/skills/skill-authoring/SKILL.md +0 -110
  293. package/templates/default/locales/zh/.mustflow/skills/source-freshness-check/SKILL.md +0 -111
  294. package/templates/default/locales/zh/.mustflow/skills/state-machine-pattern/SKILL.md +0 -214
  295. package/templates/default/locales/zh/.mustflow/skills/strategy-pattern/SKILL.md +0 -215
  296. package/templates/default/locales/zh/.mustflow/skills/structure-discovery-gate/SKILL.md +0 -159
  297. package/templates/default/locales/zh/.mustflow/skills/test-design-guard/SKILL.md +0 -162
  298. package/templates/default/locales/zh/.mustflow/skills/test-maintenance/SKILL.md +0 -122
  299. package/templates/default/locales/zh/.mustflow/skills/ui-quality-gate/SKILL.md +0 -117
  300. package/templates/default/locales/zh/.mustflow/skills/visual-review-artifact/SKILL.md +0 -127
  301. package/templates/default/locales/zh/.mustflow/skills/visual-review-artifact/assets/review-template.html +0 -286
  302. package/templates/default/locales/zh/.mustflow/skills/visual-review-artifact/resources.toml +0 -7
  303. package/templates/default/locales/zh/.mustflow/skills/web-asset-optimization/SKILL.md +0 -108
@@ -1,214 +0,0 @@
1
- ---
2
- mustflow_doc: skill.state-machine-pattern
3
- locale: zh
4
- canonical: false
5
- revision: 1
6
- lifecycle: mustflow-owned
7
- authority: procedure
8
- name: state-machine-pattern
9
- description: Apply this skill when domain objects have lifecycle state, allowed actions depend on state, status changes are scattered, or state transitions need explicit events, guards, effects, history, idempotency, and concurrency control.
10
- metadata:
11
- mustflow_schema: "1"
12
- mustflow_kind: procedure
13
- pack_id: mustflow.core
14
- skill_id: mustflow.core.state-machine-pattern
15
- command_intents:
16
- - changes_status
17
- - changes_diff_summary
18
- - test_related
19
- - test
20
- - lint
21
- - build
22
- - docs_validate_fast
23
- - test_release
24
- - mustflow_check
25
- ---
26
-
27
- # State Machine Pattern
28
-
29
- <!-- mustflow-section: purpose -->
30
- ## Purpose
31
-
32
- Keep lifecycle state changes in one explicit rule system.
33
-
34
- The state machine pattern applies when an entity moves through meaningful lifecycle states and the allowed actions, errors, follow-up work, or audit expectations depend on the current state. The core artifact is not a class hierarchy. The core artifact is the transition table: current state, event, guard, next state, and effects as data.
35
-
36
- Use this skill to prevent scattered `if`, `switch`, direct assignment, silent no-op transitions, duplicate webhook damage, and state changes that bypass audit, outbox, or concurrency rules.
37
-
38
- <!-- mustflow-section: use-when -->
39
- ## Use When
40
-
41
- - A domain object has three or more states, or fields named `status`, `state`, `phase`, `step`, or `stage`.
42
- - State determines which actions, API calls, buttons, jobs, events, or commands are allowed.
43
- - The lifecycle includes cancel, approve, reject, expire, retry, fail, refund, suspend, restore, archive, delete, publish, ship, or deliver flows.
44
- - State changes must produce history, audit records, domain events, outbox messages, or external effects.
45
- - Multiple users, workers, queues, webhooks, or external systems can attempt transitions on the same entity.
46
- - External service results change state and require pending, success, and failure states.
47
- - Code repeatedly asks whether an action is possible from the current state.
48
- - State rules are scattered across handlers, repositories, jobs, UI code, adapters, SQL queries, or broad services.
49
- - Several booleans actually encode one lifecycle and can create impossible combinations.
50
-
51
- <!-- mustflow-section: do-not-use-when -->
52
- ## Do Not Use When
53
-
54
- - The value is simple display state rather than domain lifecycle state.
55
- - The state is a simple two-value toggle with no lifecycle rules, history, side effects, concurrency risk, or irreversible transition.
56
- - State does not affect allowed actions.
57
- - The code is a pure calculation, formatter, mapper, parser, or local UI-only state update.
58
- - A simple create, read, update, delete flow only distinguishes active and deleted and has no meaningful transition rules.
59
-
60
- Two states can still require this skill when the lifecycle is meaningful, such as active to suspended to deleted, deleted being irreversible, or suspension requiring audit and authorization.
61
-
62
- <!-- mustflow-section: required-inputs -->
63
- ## Required Inputs
64
-
65
- - The entity and state field under change.
66
- - Complete state list and which states are terminal.
67
- - Complete event list and the facts each event carries.
68
- - Current places that change state, validate actions, check state, or render available actions.
69
- - Guards, authorization facts, time facts, external facts, and loaded domain data needed to decide transitions.
70
- - Effects, domain events, outbox records, audit records, transition history, idempotency keys, and concurrency protections required by the lifecycle.
71
- - Existing local patterns for `Result`, events, outbox, repositories, command handlers, pure core decisions, transition tables, tests, and documentation.
72
- - Relevant command-intent contract entries for verification.
73
-
74
- <!-- mustflow-section: preconditions -->
75
- ## Preconditions
76
-
77
- - Higher-priority instructions and `.mustflow/config/commands.toml` have been checked for the current scope.
78
- - If changing existing behavior is not the goal, current behavior is protected with tests, fixtures, examples, or explicit verification evidence.
79
- - If the state-changing operation is a user or system command, `command-pattern` has been used for payload, context, authorization, transaction, idempotency, audit, retry, and outbox execution.
80
- - If the transition decision is mixed with I/O, `pure-core-imperative-shell` has been used so the transition function stays deterministic and the shell handles persistence and effects.
81
- - If expected failures or meaningful absence are involved, `result-option` has been used for the error and absence shape.
82
- - If external services or provider responses influence transitions, `adapter-boundary` and `dependency-injection` have been used before provider facts enter the transition function.
83
-
84
- <!-- mustflow-section: allowed-edits -->
85
- ## Allowed Edits
86
-
87
- - Add or update state unions, event unions, transition tables, guard functions, effect descriptions, transition result types, and state-machine errors.
88
- - Replace direct state assignment with a transition function.
89
- - Add dispatch or shell code that loads the entity, applies the pure transition, saves state, records transition history, stores idempotency records, and writes outbox rows in one transaction.
90
- - Add available-action helpers derived from the transition table when UI or API callers need possible actions.
91
- - Add tests for valid transitions, invalid transitions, guard success and failure, terminal states, generated effects, duplicate events, concurrency conflicts, and transition history.
92
- - Add lifecycle documentation or diagrams only when this repository already documents domain state machines or the changed domain needs an operational reference.
93
- - Do not create a class hierarchy just to represent states.
94
- - Do not duplicate the server state machine in UI logic.
95
-
96
- <!-- mustflow-section: procedure -->
97
- ## Procedure
98
-
99
- 1. Decide whether the lifecycle warrants a state machine.
100
- - Apply it when state controls allowed actions, external work, audit, retries, concurrency, or long-running lifecycle behavior.
101
- - Avoid it for simple display values and toggles without transition rules.
102
- 2. Replace boolean clusters with explicit state.
103
- - Convert combinations such as `isPaid`, `isCancelled`, `isShipped`, and `isRefunded` into one lifecycle state or several independent state machines.
104
- - Make states mutually exclusive within one state machine.
105
- 3. Name states by domain meaning.
106
- - Prefer states such as `DRAFT`, `PENDING_REVIEW`, `APPROVED`, `PAYMENT_PENDING`, `PAID`, `FULFILLMENT_PENDING`, `SHIPPED`, `DELIVERED`, `CANCELLED`, `REFUND_PENDING`, `REFUNDED`, `EXPIRED`, or `ARCHIVED`.
107
- - Avoid UI or placeholder names such as `STEP_1`, `STEP_2`, `BUTTON_DISABLED`, `GRAY`, `READY2`, `TEMP`, and broad states such as `PROCESSING` when a more specific waiting state exists.
108
- 4. Name events as facts that happened.
109
- - Prefer events such as `PAYMENT_STARTED`, `PAYMENT_SUCCEEDED`, `PAYMENT_FAILED`, `CANCEL_REQUESTED`, `REFUND_APPROVED`, `SHIPMENT_CREATED`, `DELIVERY_CONFIRMED`, `TIMEOUT_REACHED`, and `EMAIL_VERIFIED`.
110
- - Avoid command-like or meaningless events such as `SET_STATUS`, `CHANGE_STATUS`, `UPDATE_STATE`, `MAKE_ACTIVE`, `NEXT`, and `UPDATE`.
111
- - Distinguish commands from events: commands request work, events record what happened.
112
- 5. Write the transition table first.
113
- - Include every source state, allowed event, guard name, target state, and effect description.
114
- - Include terminal states explicitly with no outgoing transitions when they are truly terminal.
115
- - Do not hide transition rules inside handler branches, repository filters, database queries, adapter code, or UI code.
116
- 6. Keep guards pure.
117
- - Guards may inspect entity state, event data, context facts, loaded external facts, current time passed through context, and authorization facts passed through context.
118
- - Guards must not query databases, call SDKs, send messages, write logs, mutate state, read current time directly, generate random values, or trigger external work.
119
- - If a guard needs an external fact, load it before transition and pass the normalized fact through context.
120
- 7. Model external work with pending, success, and failure events.
121
- - Do not jump directly from request to success for payment, refund, shipment, email, file processing, AI processing, or other external operations.
122
- - Use states such as `PAYMENT_PENDING`, `REFUND_PENDING`, `FULFILLMENT_PENDING`, or `ANALYSIS_PENDING`, then model provider success and failure as separate events.
123
- 8. Model time as events.
124
- - Expiration, scheduled cancellation, automatic approval, automatic archive, retry window elapsed, and timeout should enter the state machine as events.
125
- - Do not scatter direct time checks that assign state outside the transition function.
126
- 9. Keep transition functions pure.
127
- - Inputs are entity, event, and context.
128
- - Success returns previous state, next state, updated entity or patch, transition log data, domain events, and effect descriptions.
129
- - Failure returns a typed error such as invalid transition, guard failed, concurrent transition, or duplicate event conflict.
130
- - The pure transition function must not persist, publish, send, call providers, log, read environment variables, read current time directly, or mutate external state.
131
- 10. Separate transition from persistence and effects.
132
- - Application or shell code loads the entity, calls the pure transition, and persists the result.
133
- - State update, version update, transition log, processed event record, and outbox record should be saved in one transaction when the state is durable.
134
- - External effects should run after commit through an outbox, pending effect table, queue, or worker.
135
- 11. Protect durable state with concurrency control.
136
- - Use optimistic version checks, compare-and-swap saves, unique constraints, row locks, or conditional updates.
137
- - If another transition wins first, return a conflict, reload and recompute, or enqueue a domain-specific retry only when that policy is explicit.
138
- 12. Make duplicate events safe.
139
- - Include idempotency keys, provider event identifiers, webhook identifiers, command identifiers, or an equivalent deduplication key.
140
- - Same key and same payload should return the prior result.
141
- - Same key and different payload should return a duplicate conflict.
142
- - Different key with an impossible current state should return invalid transition rather than silently succeeding.
143
- 13. Record transition history when the lifecycle matters operationally.
144
- - History should include entity type, entity identifier, from state, event type, to state, actor identifier when known, idempotency key, payload hash, reason when safe, and timestamp from context.
145
- - Use transition history for debugging, customer support, dispute handling, audit, and security review.
146
- 14. Derive available actions from the state machine.
147
- - UI or API layers may display available actions, but they must not own an independent copy of transition rules.
148
- - Prefer a server-side helper that evaluates possible events or exposes allowed actions derived from the transition table.
149
- - Treat UI checks as guidance only. Server transition validation remains authoritative.
150
- 15. Split state machines when one state string explodes.
151
- - If payment, fulfillment, refund, moderation, or account status change independently, use separate state machines.
152
- - State-machine splits require explicit cross-machine invariants, such as fulfillment not shipping before payment succeeds.
153
- - Put cross-machine coordination in a domain service, command handler, workflow, or pure policy that calls the smaller machines.
154
- 16. Document only the useful lifecycle contract.
155
- - For important domains, document state list, event list, transition table, terminal states, guards, effects, concurrency method, duplicate-event handling, and any cross-machine invariants.
156
- - Diagrams are secondary. The code transition table is the source of truth.
157
- 17. Test from the transition table.
158
- - Test every valid transition.
159
- - Test representative invalid transitions, especially terminal states and dangerous skipped states.
160
- - Test guard success and guard failure separately.
161
- - Test that successful transitions produce the expected effects or outbox descriptions.
162
- - Test that failed transitions produce no effects.
163
- - Test duplicate events, duplicate conflicts, transition history, and concurrency behavior when the state is persisted.
164
-
165
- <!-- mustflow-section: postconditions -->
166
- ## Postconditions
167
-
168
- - State cannot be changed outside the transition function or dispatch path.
169
- - Every allowed transition is visible in one transition table.
170
- - Impossible transitions return explicit errors instead of being ignored.
171
- - Guards are pure and external facts are passed through context.
172
- - External work is represented through pending, success, and failure events, with effects executed after persistence.
173
- - Durable state transitions use concurrency control and duplicate-event handling when needed.
174
- - Important lifecycle changes leave transition history and outbox or effect records.
175
- - Tests cover the transition table and the highest-risk invalid, duplicate, and concurrent paths.
176
-
177
- <!-- mustflow-section: verification -->
178
- ## Verification
179
-
180
- Use configured oneshot command intents when available:
181
-
182
- - `changes_status`
183
- - `changes_diff_summary`
184
- - `test_related`
185
- - `test`
186
- - `lint`
187
- - `build`
188
- - `docs_validate_fast`
189
- - `test_release`
190
- - `mustflow_check`
191
-
192
- Choose the narrowest configured verification that covers the changed state machine, dispatch path, tests, templates, docs, release metadata, and mustflow routing.
193
-
194
- <!-- mustflow-section: failure-handling -->
195
- ## Failure Handling
196
-
197
- - If states or events are unknown, stop and list the missing lifecycle decisions before coding.
198
- - If direct assignment remains outside the transition path, report the remaining bypass or finish removing it before claiming the state machine is enforced.
199
- - If a guard needs I/O, move the I/O to the shell and pass the result as context.
200
- - If external effects cannot be made reliable through outbox, pending actions, provider idempotency, or compensation, report the reliability gap.
201
- - If duplicate-event handling is missing for webhook, queue, payment, refund, or worker flows, do not call the transition safe to retry.
202
- - If a single state machine is becoming unreadable, split independent lifecycle dimensions and document cross-machine invariants.
203
-
204
- <!-- mustflow-section: output-format -->
205
- ## Output Format
206
-
207
- - Entity and lifecycle modeled
208
- - States, terminal states, and events introduced or changed
209
- - Transition table location and source-of-truth note
210
- - Guards and context facts
211
- - Effects, outbox, history, idempotency, and concurrency choices
212
- - Direct state assignments removed or remaining bypasses
213
- - Tests or verification evidence
214
- - Skipped checks and remaining state-machine risk
@@ -1,215 +0,0 @@
1
- ---
2
- mustflow_doc: skill.strategy-pattern
3
- locale: zh
4
- canonical: false
5
- revision: 3
6
- lifecycle: mustflow-owned
7
- authority: procedure
8
- name: strategy-pattern
9
- description: Apply this skill when code has multiple interchangeable algorithms, policies, calculations, provider choices, scoring methods, sorting methods, recommendation methods, pricing rules, discount rules, shipping methods, notification methods, permission policies, feature-flag variants, or repeated if/switch branches that choose how to do the same kind of work.
10
- metadata:
11
- mustflow_schema: "1"
12
- mustflow_kind: procedure
13
- pack_id: mustflow.core
14
- skill_id: mustflow.core.strategy-pattern
15
- command_intents:
16
- - changes_status
17
- - changes_diff_summary
18
- - test_related
19
- - test
20
- - lint
21
- - build
22
- - docs_validate_fast
23
- - test_release
24
- - mustflow_check
25
- ---
26
-
27
- # Strategy Pattern
28
-
29
- <!-- mustflow-section: purpose -->
30
- ## Purpose
31
-
32
- Separate changeable algorithms, policies, calculations, and execution methods from the stable workflow that uses them.
33
-
34
- The strategy pattern applies when several implementations serve the same purpose but differ in how they calculate, decide, rank, price, discount, ship, pay, notify, authorize, search, recommend, or call a provider. The caller should depend on a shared strategy contract, not on concrete implementation branches.
35
-
36
- Use this skill to reduce repeated `if` and `switch` branches, keep policy changes out of core flow code, add new variants with minimal existing-code edits, and test each policy independently.
37
-
38
- <!-- mustflow-section: use-when -->
39
- ## Use When
40
-
41
- - Several implementations do the same kind of work, such as pricing, discounts, shipping fees, payment handling, permission checks, ranking, search, recommendation, notification, file conversion, retry policy, or provider selection.
42
- - Branches differ by method, plan, region, country, user tier, feature flag, experiment group, input type, provider, format, or business policy.
43
- - `if`, `else if`, `switch`, `case`, or dictionary dispatch repeatedly chooses the variant and then runs variant-specific logic inline.
44
- - Adding a new variant requires modifying a central service, handler, controller, command handler, or pure decision function.
45
- - Variant selection and variant execution are mixed in one function.
46
- - Variant-specific tests would be clearer than testing one large branching function.
47
- - A feature would otherwise introduce subclasses, template methods, or base classes just to reuse or swap behavior.
48
- - Runtime configuration or feature flags choose between old and new algorithms.
49
- - One variant is an honest no-op, disabled, identity, empty, or zero policy that shares the same contract as real variants.
50
-
51
- <!-- mustflow-section: do-not-use-when -->
52
- ## Do Not Use When
53
-
54
- - There is only one implementation or two stable branches with little chance of growth.
55
- - Branches perform different user intents or different use cases rather than different methods for the same purpose.
56
- - Lifecycle state and allowed transitions are the main concern; use `state-machine-pattern`.
57
- - Object construction is the only thing that varies; use a factory or local construction helper instead.
58
- - External provider shape, protocol, SDK response, timeout, retry, or error translation is the main concern; use `adapter-boundary`.
59
- - A state-changing operation needs payload, actor context, transaction, idempotency, audit, retry, and outbox semantics; use `command-pattern`.
60
- - A caller needs one stable high-level operation that coordinates several dependencies or subsystem steps; use `facade-pattern` and keep strategies only for interchangeable policies inside that workflow.
61
- - A pure business decision is mixed with I/O; use `pure-core-imperative-shell` first.
62
- - The strategy variants would combine many independent dimensions into an exploding list of classes; split the dimensions into smaller policies instead.
63
-
64
- <!-- mustflow-section: required-inputs -->
65
- ## Required Inputs
66
-
67
- - The stable workflow that needs variable behavior.
68
- - The variants and the shared purpose they serve.
69
- - Current branch locations, strategy-like implementations, and selection logic.
70
- - Common input facts each variant needs.
71
- - Common output shape and expected failure model.
72
- - Selection criteria, such as validated user option, server-side policy, config value, feature flag, region, plan, or provider capability.
73
- - Local patterns for functions, policy objects, registries, dependency injection, decorators, `Result`, tests, and observability.
74
- - Relevant command-intent contract entries for verification.
75
-
76
- <!-- mustflow-section: preconditions -->
77
- ## Preconditions
78
-
79
- - Higher-priority instructions and `.mustflow/config/commands.toml` have been checked for the current scope.
80
- - The variants have one shared purpose. If they do not, split the workflow into separate use cases instead of forcing a strategy abstraction.
81
- - If preserving existing behavior, use `behavior-preserving-refactor` before moving branch bodies.
82
- - If the strategy depends on external systems, use `adapter-boundary` and `dependency-injection` so provider details stay outside the strategy contract.
83
- - If normal business failures or unsupported variants are expected, use `result-option` for explicit return and error shapes.
84
- - If one strategy represents intentional absence or disabled behavior, use `null-object-pattern` to verify that the neutral behavior does not fake success or hide a required failure.
85
- - If a strategy affects lifecycle transitions, use `state-machine-pattern` for the transition table and use strategies only for replaceable calculations or policies inside that lifecycle.
86
- - If the strategy is only one part of a larger multi-step subsystem workflow, use `facade-pattern` for the caller-facing workflow and keep the strategy behind its contract.
87
-
88
- <!-- mustflow-section: allowed-edits -->
89
- ## Allowed Edits
90
-
91
- - Add or update strategy function types, interfaces, policy objects, concrete strategies, selectors, resolvers, registries, decorators, and focused tests.
92
- - Move inline variant logic from handlers, services, command handlers, or core decision functions into named strategies.
93
- - Keep simple strategies as functions when they are pure calculations.
94
- - Use classes only when dependencies, framework injection, complex helpers, or test doubles justify them.
95
- - Add observability around selected strategy keys when it helps operations and does not leak sensitive data.
96
- - Do not create broad `Manager`, `Processor`, `Handler`, `Advanced`, `Special`, or `New` strategy names.
97
- - Do not add strategy ceremony for trivial stable branches.
98
-
99
- <!-- mustflow-section: procedure -->
100
- ## Procedure
101
-
102
- 1. Classify the branch.
103
- - Use strategy when branches choose how to do the same work.
104
- - Do not use strategy when branches choose different user intents, object creation only, external shape translation, lifecycle transitions, or command execution units.
105
- 2. Name the strategy family by business purpose.
106
- - Prefer names such as `ShippingFeeStrategy`, `DiscountPolicy`, `PaymentCaptureStrategy`, `RecommendationRankingStrategy`, or `PermissionPolicy`.
107
- - Avoid vague names such as `Strategy1`, `NewStrategy`, `AdvancedStrategy`, `SpecialStrategy`, `Handler`, `Processor`, and `Manager`.
108
- 3. Define one shared contract.
109
- - Fix the input type, output type, and expected error shape.
110
- - Keep the input object narrow enough to describe the strategy family, not the entire application context.
111
- - Every strategy in the family must accept the same input shape and return the same output shape.
112
- 4. Prefer function strategies for simple pure policies.
113
- - Use a function type when the policy is stateless, deterministic, and has no external dependency.
114
- - Use a class or object when the strategy needs injected collaborators, configuration, complex helpers, lifecycle management, or framework container integration.
115
- 5. Separate selection from execution.
116
- - A selector or resolver chooses the strategy key or strategy implementation.
117
- - The strategy executes the variant-specific behavior.
118
- - The context or service owns the workflow and calls the selected strategy through the shared contract.
119
- - Conditions do not need to disappear; they should move to selection and stop containing variant execution details.
120
- 6. Keep the context ignorant of concrete strategies.
121
- - The context may depend on a selector, resolver, registry, or one injected strategy contract.
122
- - It should not instantiate concrete strategies or branch on concrete strategy names.
123
- 7. Keep strategy registration discoverable.
124
- - Register strategy implementations in one searchable registry, module, dependency-injection assembly, or configuration binding.
125
- - Adding a strategy should usually require only a new implementation, registration, and tests, plus a typed key update when the key set is closed.
126
- 8. Treat unknown strategy keys explicitly.
127
- - Do not silently fall back when a provided key is invalid.
128
- - Distinguish missing optional input that should use an explicit default from unsupported input that should return an error.
129
- - Validate user-provided keys before resolving a strategy.
130
- - Keep explicit default strategies separate from invalid-key fallback. A no-op or disabled strategy is valid only when it is selected by an explicit rule.
131
- 9. Do not let user input directly select privileged behavior.
132
- - A request may contain a desired option, but server-side validation and business rules must decide the final strategy.
133
- - This matters for pricing, discounts, payment methods, authorization, shipping, quotas, experiments, and provider selection.
134
- 10. Keep strategies stateless per request.
135
- - Store dependencies, immutable configuration, and static lookup data on strategy instances.
136
- - Do not store current user, current order, request body, transaction state, intermediate result, or other request-specific data in strategy fields.
137
- - Pass request-specific facts through the input object.
138
- 11. Split validation correctly.
139
- - Common validation belongs before selection or before strategy execution.
140
- - Variant-specific validation belongs inside the strategy.
141
- - Expected business failures should return typed `Result` values or local equivalents, not raw strings or normal-flow exceptions.
142
- - A no-op, disabled, identity, empty, or zero strategy must return an honest neutral result and must not pretend that a side effect, payment, permission grant, save, upload, or audit record happened.
143
- 12. Avoid strategy combination explosion.
144
- - If strategy names grow by combining region, plan, item type, speed, provider, and user tier, split those dimensions into smaller policies and compose them.
145
- - Use a composite strategy only when each sub-policy has one clear responsibility.
146
- 13. Keep configuration in the right role.
147
- - Configuration may choose a strategy key or enable a feature-flag variant.
148
- - Do not hide complex business rules as untyped string expressions in config files.
149
- - Feature flags should usually be read by the selector or shell, not inside individual strategies.
150
- - Remove obsolete experiment strategies after the experiment ends.
151
- 14. Add observability at the context or decorator boundary when useful.
152
- - Record selected strategy key, safe selection reason, duration, outcome, and error code.
153
- - Do not log secrets, raw personal data, payment payloads, tokens, or sensitive provider responses.
154
- - Prefer decorators for repeated logging, timing, retry, caching, or metrics behavior across strategies.
155
- 15. Test the layers separately.
156
- - Strategy contract tests verify every strategy returns the expected shape.
157
- - Strategy-specific tests verify each policy's unique behavior.
158
- - Selector tests verify which strategy is chosen for each selection condition.
159
- - Context tests use fake strategies and verify orchestration, not policy internals.
160
- 16. Refactor incrementally.
161
- - Extract one strategy family at a time.
162
- - Move existing branch bodies into strategies without changing behavior unless the task explicitly asks for a behavior fix.
163
- - Remove dead branches and direct concrete strategy knowledge from the context after tests pass.
164
-
165
- <!-- mustflow-section: postconditions -->
166
- ## Postconditions
167
-
168
- - Strategy variants have one shared purpose and one shared contract.
169
- - The stable context no longer contains variant-specific execution branches.
170
- - Strategy selection is centralized in a selector, resolver, registry, or assembly boundary.
171
- - Unknown or unauthorized strategy choices fail explicitly.
172
- - User input is validated before it affects strategy choice.
173
- - Strategies do not store request-specific mutable state.
174
- - New variants can be added with minimal changes to existing workflow code.
175
- - Tests cover strategy behavior, selection behavior, and context orchestration at the right layers.
176
-
177
- <!-- mustflow-section: verification -->
178
- ## Verification
179
-
180
- Use configured oneshot command intents when available:
181
-
182
- - `changes_status`
183
- - `changes_diff_summary`
184
- - `test_related`
185
- - `test`
186
- - `lint`
187
- - `build`
188
- - `docs_validate_fast`
189
- - `test_release`
190
- - `mustflow_check`
191
-
192
- Choose the narrowest configured verification that covers changed strategy code, selectors, registries, tests, templates, docs, release metadata, and mustflow routing.
193
-
194
- <!-- mustflow-section: failure-handling -->
195
- ## Failure Handling
196
-
197
- - If variants do not share a purpose, stop and split the use cases instead of forcing a strategy interface.
198
- - If input or output cannot be made common without a giant dependency object, split the strategy family into smaller policies.
199
- - If the context still knows concrete strategy names, move that knowledge into a selector, resolver, registry, or assembly root.
200
- - If unknown keys silently default, replace the fallback with an explicit default case for missing input or an explicit error for unsupported input.
201
- - If strategy count is growing by combinations, decompose independent dimensions before adding more classes.
202
- - If a strategy needs I/O but the decision should be pure, move I/O to the shell or adapter and pass normalized facts into the strategy.
203
-
204
- <!-- mustflow-section: output-format -->
205
- ## Output Format
206
-
207
- - Strategy family and shared purpose
208
- - Contract input, output, and failure shape
209
- - Strategies added, reused, or deliberately avoided
210
- - Selector, resolver, registry, or assembly location
211
- - User-input validation and default behavior
212
- - State, command, adapter, or pure-core boundaries used with this skill
213
- - Facade boundary used or intentionally avoided
214
- - Tests or verification evidence
215
- - Skipped checks and remaining strategy risk
@@ -1,159 +0,0 @@
1
- ---
2
- mustflow_doc: skill.structure-discovery-gate
3
- locale: zh
4
- canonical: false
5
- revision: 12
6
- lifecycle: mustflow-owned
7
- authority: procedure
8
- name: structure-discovery-gate
9
- description: Apply this skill before introducing new feature structure, folders, file boundaries, routing, data models, or integration boundaries.
10
- metadata:
11
- mustflow_schema: "1"
12
- mustflow_kind: procedure
13
- pack_id: mustflow.core
14
- skill_id: mustflow.core.structure-discovery-gate
15
- command_intents:
16
- - changes_status
17
- - changes_diff_summary
18
- - docs_validate_fast
19
- - test_release
20
- - mustflow_check
21
- ---
22
-
23
- # Structure Discovery Gate
24
-
25
- <!-- mustflow-section: purpose -->
26
- ## Purpose
27
-
28
- Find hidden structure decisions before coding so new files, folders, names, routing, data models, and integration boundaries reduce future change cost instead of producing a neat but brittle tree.
29
-
30
- <!-- mustflow-section: use-when -->
31
- ## Use When
32
-
33
- - The task asks for a new feature, module, folder layout, architecture, scaffold, refactor, API integration, website, app flow, routing structure, data model, state model, or file split.
34
- - A named technology or service may be only an implementation choice rather than the product domain, such as AdSense, Stripe, Supabase, Firebase, Resend, SendGrid, Google Analytics, Plausible, or a CMS.
35
- - The request may hide costly structural decisions around localization, SEO, authentication, authorization, payments, ads, analytics, admin workflows, deployment, content management, storage, retention, or external service replacement.
36
- - The agent is about to create new top-level folders, shared modules, providers, adapters, services, constants, or public names.
37
-
38
- <!-- mustflow-section: do-not-use-when -->
39
- ## Do Not Use When
40
-
41
- - The task is a tiny mechanical edit with an obvious target file and no new boundary.
42
- - The user explicitly asks for a disposable prototype, spike, or one-off example where future structure is out of scope.
43
- - A structure decision has already been made in current project instructions, accepted design docs, or the immediately preceding user answer.
44
- - The task is only to match an existing local pattern; use `pattern-scout` unless hidden product assumptions may still change the shape.
45
-
46
- <!-- mustflow-section: required-inputs -->
47
- ## Required Inputs
48
-
49
- - User request and intended product or code change.
50
- - Current project instructions, relevant context, and nearby implementation patterns when available.
51
- - Known target platform, language, framework, package, or deployment constraints.
52
- - Any named external services, content sources, user roles, locales, data stores, algorithms, policies, feature flags, or revenue surfaces in the request.
53
- - Risk surfaces that could require a plan/apply gate, capability object, Result or Option return shape, command execution unit, facade entry point, invariant policy, state machine, pure core with an imperative shell, dependency injection boundary, adapter boundary, composition over inheritance, injected clock, state transition table, or idempotency ledger.
54
- - Optional collaborators whose absence might require a null object, disabled implementation, identity implementation, deny-all policy, or explicit failure.
55
- - Relevant command-intent contract entries for later verification.
56
-
57
- <!-- mustflow-section: preconditions -->
58
- ## Preconditions
59
-
60
- - The task matches the Use When conditions and does not match the Do Not Use When exclusions.
61
- - Required inputs are available from current context or can be stated as unknown without guessing.
62
- - Higher-priority instructions and `.mustflow/config/commands.toml` have been checked for the current scope.
63
-
64
- <!-- mustflow-section: allowed-edits -->
65
- ## Allowed Edits
66
-
67
- - Use this skill to shape the plan, questions, assumptions, file boundaries, and the smallest resulting implementation.
68
- - Edit only files needed for the accepted or reasonably assumed structure.
69
- - Do not create broad design documents, policy files, shared folders, provider systems, or abstractions just because they sound tidy.
70
- - Do not treat this skill as permission to delay every task for a long interview; ask only questions that can change the structure.
71
-
72
- <!-- mustflow-section: procedure -->
73
- ## Procedure
74
-
75
- 1. Restate the requested change as the product capability or code responsibility, not just the named technology.
76
- 2. Identify hidden decisions that could change routing, folder names, file boundaries, data model, state ownership, environment variables, tests, deployment, SEO, localization, external integrations, or legal and policy requirements.
77
- 3. Classify each decision:
78
- - Blocking: the answer can change the basic structure and cannot be safely assumed.
79
- - Structure-impacting: the answer changes boundaries, but a conservative default can be stated if the user does not answer.
80
- - Preference: the answer affects styling, wording, or minor details and should not block structure.
81
- 4. Ask at most five high-value questions before coding. Prioritize localization, authentication, authorization, payments, ads, personal data, destructive data actions, admin workflows, SEO, content storage, and external service replacement.
82
- 5. For any question not asked, state the default assumption briefly. Defaults should keep future changes possible without adding speculative layers.
83
- 6. Select structure patterns only when the task's risk shape requires them:
84
- - Use a plan/apply gate for destructive, bulk, migration, billing, permission, publishing, or external-send operations that need review before execution.
85
- - Use a capability object when a function should require a specific granted action instead of reading broad user or role state.
86
- - Use Result and Option values for expected business failures, meaningful absence, not found, invalid input, denied access, stale state, or blocked policy. Use `result-option` before editing that return-shape contract.
87
- - Use a Null Object only when an optional collaborator can safely implement the same interface with honest neutral behavior and the caller should not branch on presence. Use `null-object-pattern` before editing that optional dependency boundary.
88
- - Use a command pattern when a state-changing user or system intent needs explicit payload, context, authorization, transaction, idempotency, outbox, audit, retry, concurrency, or queue and worker reuse. Use `command-pattern` before editing that execution unit.
89
- - Use a facade pattern when controllers, handlers, workers, command handlers, services, or UI events need one stable high-level entry point over a repeated multi-step subsystem workflow. Use `facade-pattern` before editing that entry point.
90
- - Use invariant policy modules when a state change must preserve non-negotiable rules, such as last-owner, paid-order, refund, or entitlement constraints.
91
- - Use a state machine when status, state, phase, step, or stage controls allowed events, terminal states, guards, effects, transition history, duplicate-event handling, or concurrency. Use `state-machine-pattern` before editing that lifecycle.
92
- - Use a strategy pattern when several algorithms, policies, calculations, provider choices, feature-flag variants, or scoring methods share one purpose and should not keep branching inside the stable workflow. Use `strategy-pattern` before editing that strategy family.
93
- - Use pure core with an imperative shell when business decisions, validation, authorization, pricing, eligibility, state transitions, domain events, or effect descriptions would otherwise be mixed with I/O, clocks, generated identifiers, randomness, environment reads, or framework objects.
94
- - Use composition over inheritance when behavior varies by multiple dimensions, class inheritance is proposed for implementation reuse, or framework subclasses could stay thin by delegating to explicit collaborators.
95
- - Use dependency injection when core logic would otherwise construct, import, resolve, or hide databases, SDKs, clocks, random generators, configuration, loggers, framework objects, filesystems, queues, AI clients, payment gateways, or email senders.
96
- - Use an adapter boundary when external APIs, databases, model responses, webhooks, files, queues, caches, framework objects, or command output cross into internal logic or leave it.
97
- - Inject time or a time context when expiration, scheduling, retries, leases, or rate windows affect behavior.
98
- - Use explicit state transitions when three or more states have meaningful allowed moves.
99
- - Use an action ledger or idempotency key when repeating a side effect would be harmful.
100
- 7. Prefer the smallest local version of the selected pattern. Do not add a framework, base class, service locator, global event bus, broad repository layer, or abstract factory when a plain function, table, adapter, or narrow policy object is enough.
101
- 8. Separate product domains from vendor implementations. Use broad names at the product boundary and specific names inside provider or adapter internals.
102
- - Prefer `monetization/ads/providers/adsense` over top-level `adsense`.
103
- - Prefer `payments/providers/stripe` over top-level `stripe`.
104
- - Prefer `notifications/email/providers/resend` over top-level `resend`.
105
- - Prefer `analytics/providers/google-analytics` over top-level `googleAnalytics`.
106
- 9. Propose the smallest folder and file structure that follows the answers and assumptions. For each new file or folder, state its responsibility and what it must not contain.
107
- 10. Check the structure against local precedent with `pattern-scout` when the repository already has a nearby pattern.
108
- 11. If the selected structure changes expected failure, meaningful absence, thrown business errors, null returns, or public error mapping, use `result-option` before editing that scope.
109
- 12. If the selected structure creates or repairs a state-changing execution unit, use `command-pattern` before editing that scope.
110
- 13. If the selected structure introduces or repairs lifecycle state transitions, use `state-machine-pattern` before editing that scope.
111
- 14. If the selected structure introduces interchangeable algorithms, policies, calculations, provider choices, or feature-flag variants, use `strategy-pattern` before editing that scope.
112
- 15. If the selected structure introduces one high-level entry point over several subsystem collaborators, use `facade-pattern` before editing that scope.
113
- 16. If the selected structure separates business decisions from execution, use `pure-core-imperative-shell` before editing that scope.
114
- 17. If the selected structure introduces inheritance, base classes, protected state, or subclass variants, use `composition-over-inheritance` before editing that scope.
115
- 18. If the selected structure introduces or repairs an external dependency boundary, use `dependency-injection` for construction and collaborator flow, and `adapter-boundary` for external data, protocol, error, timeout, retry, idempotency, security, and observability handling.
116
- 19. Implement only after the questions, assumptions, structure, dependency direction, and verification surface are clear enough for the task size.
117
-
118
- <!-- mustflow-section: postconditions -->
119
- ## Postconditions
120
-
121
- - The final structure follows an explicit set of answers or assumptions.
122
- - Top-level names reflect product responsibilities rather than replaceable vendor names unless the vendor is the product itself.
123
- - New folders and files have clear responsibilities, non-responsibilities, and dependency direction.
124
- - Any skipped question, deferred decision, or intentionally narrow assumption is reported.
125
-
126
- <!-- mustflow-section: verification -->
127
- ## Verification
128
-
129
- Use configured oneshot command intents when available:
130
-
131
- - `changes_status`
132
- - `changes_diff_summary`
133
- - `docs_validate_fast`
134
- - `test_release`
135
- - `mustflow_check`
136
-
137
- Also run narrower configured tests or builds required by the changed source, template, documentation, or public contract.
138
-
139
- <!-- mustflow-section: failure-handling -->
140
- ## Failure Handling
141
-
142
- - If too many structural unknowns remain, ask only the highest-impact blocking questions and report the assumptions that are unsafe to make.
143
- - If the user does not answer non-blocking questions, proceed with conservative defaults and keep the first implementation small.
144
- - If a vendor name has already leaked into broad public structure, either localize it inside a provider or report why renaming is out of scope.
145
- - If a proposed abstraction has only one known use and no likely replacement pressure, keep it close to the feature instead of moving it to shared code.
146
- - If this skill overlaps with `codebase-orientation`, use orientation to map the existing area first, then return to this skill for the structure decision.
147
-
148
- <!-- mustflow-section: output-format -->
149
- ## Output Format
150
-
151
- - Capability or responsibility being built
152
- - Blocking questions asked, or none
153
- - Structure-impacting assumptions
154
- - Proposed files and responsibilities
155
- - Dependency direction
156
- - Structural patterns selected or intentionally skipped
157
- - Local pattern used or reason no pattern applies
158
- - Command intents run
159
- - Skipped checks and remaining structure risk