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
@@ -0,0 +1,376 @@
1
+ const HANDOFF_SCHEMA_VERSION = '1';
2
+ export const MAX_HANDOFF_RECORD_BYTES = 256 * 1024;
3
+ const MAX_STRING_LENGTH = 2_000;
4
+ const MAX_ARRAY_ITEMS = 100;
5
+ const MAX_OBJECT_DEPTH = 8;
6
+ const ALLOWED_TOP_LEVEL_KEYS = new Set([
7
+ 'schema_version',
8
+ 'kind',
9
+ 'task_id',
10
+ 'goal',
11
+ 'scope',
12
+ 'non_goals',
13
+ 'acceptance_criteria',
14
+ 'source_refs',
15
+ 'changed_surfaces',
16
+ 'verification_plan',
17
+ 'coverage',
18
+ 'remaining_risks',
19
+ 'next_restart_point',
20
+ ]);
21
+ const ALLOWED_VERIFICATION_PLAN_KEYS = new Set([
22
+ 'intent',
23
+ 'reason',
24
+ 'status',
25
+ 'receipt_path',
26
+ 'skip_reason',
27
+ ]);
28
+ const ALLOWED_COVERAGE_KEYS = new Set(['status', 'requirement', 'evidence', 'gap']);
29
+ const RECORD_KINDS = new Set(['work_item', 'handoff']);
30
+ const COVERAGE_STATUSES = new Set(['covered', 'partial', 'missing', 'blocked']);
31
+ const VERIFICATION_STATUSES = new Set(['planned', 'run', 'skipped']);
32
+ const FORBIDDEN_KEY_RULES = [
33
+ {
34
+ code: 'forbidden_transcript_or_log_field',
35
+ pattern: /^(?:transcript|raw_transcript|chat|conversation|messages|terminal_log|command_log|logs?|stdout|stderr|raw_output|full_output)$/iu,
36
+ message: 'Handoff records must not store raw chats, transcripts, terminal logs, or command output.',
37
+ },
38
+ {
39
+ code: 'forbidden_secret_field',
40
+ pattern: /(?:secret|password|token|api[_-]?key|credential|private[_-]?key)/iu,
41
+ message: 'Handoff records must not store secrets, credentials, tokens, or key material.',
42
+ },
43
+ {
44
+ code: 'forbidden_hidden_reasoning_field',
45
+ pattern: /(?:reasoning|chain[_-]?of[_-]?thought|hidden[_-]?thoughts?)/iu,
46
+ message: 'Handoff records must not store hidden reasoning or chain-of-thought content.',
47
+ },
48
+ {
49
+ code: 'forbidden_memory_field',
50
+ pattern: /(?:memory|memory[_-]?summary|broad[_-]?summary)/iu,
51
+ message: 'Handoff records must not become broad memory summaries.',
52
+ },
53
+ {
54
+ code: 'forbidden_worker_state_field',
55
+ pattern: /(?:worker[_-]?state|autonomous[_-]?loop|background[_-]?process|persona|agent[_-]?state)/iu,
56
+ message: 'Handoff records must not store autonomous worker state or background-loop state.',
57
+ },
58
+ {
59
+ code: 'forbidden_command_authority_field',
60
+ pattern: /^(?:argv|cmd|run_policy|lifecycle|stdin|timeout_seconds|writes|network|destructive|required_after|skip_validation|agent_action|command_authority)$/iu,
61
+ message: 'Handoff records must not include command-authority fields that bypass commands.toml.',
62
+ },
63
+ ];
64
+ const SECRET_VALUE_RULES = [
65
+ {
66
+ code: 'secret_like_private_key',
67
+ pattern: /-----BEGIN [A-Z ]*PRIVATE KEY-----/u,
68
+ message: 'Value looks like private key material.',
69
+ },
70
+ {
71
+ code: 'secret_like_token',
72
+ pattern: /\b(?:sk-[A-Za-z0-9_-]{12,}|ghp_[A-Za-z0-9_]{12,}|github_pat_[A-Za-z0-9_]{12,}|xox[abprs]-[A-Za-z0-9-]{12,})\b/u,
73
+ message: 'Value looks like an API token or service token.',
74
+ },
75
+ {
76
+ code: 'secret_like_aws_access_key',
77
+ pattern: /\bAKIA[0-9A-Z]{16}\b/u,
78
+ message: 'Value looks like an AWS access key.',
79
+ },
80
+ {
81
+ code: 'secret_like_assignment',
82
+ pattern: /\b(?:password|token|secret|api[_-]?key)\s*[:=]\s*\S+/iu,
83
+ message: 'Value looks like an inline secret assignment.',
84
+ },
85
+ ];
86
+ function isRecord(value) {
87
+ return value !== null && typeof value === 'object' && !Array.isArray(value);
88
+ }
89
+ function isString(value) {
90
+ return typeof value === 'string';
91
+ }
92
+ function normalizeKey(value) {
93
+ return value.replaceAll('-', '_').toLowerCase();
94
+ }
95
+ function makeEmptySummary() {
96
+ return {
97
+ scope_count: 0,
98
+ acceptance_criteria_count: 0,
99
+ source_ref_count: 0,
100
+ verification_plan_count: 0,
101
+ coverage_count: 0,
102
+ remaining_risk_count: 0,
103
+ };
104
+ }
105
+ function countArray(value) {
106
+ return Array.isArray(value) ? value.length : 0;
107
+ }
108
+ function getSummary(value) {
109
+ if (!isRecord(value)) {
110
+ return makeEmptySummary();
111
+ }
112
+ return {
113
+ scope_count: countArray(value.scope),
114
+ acceptance_criteria_count: countArray(value.acceptance_criteria),
115
+ source_ref_count: countArray(value.source_refs),
116
+ verification_plan_count: countArray(value.verification_plan),
117
+ coverage_count: countArray(value.coverage),
118
+ remaining_risk_count: countArray(value.remaining_risks),
119
+ };
120
+ }
121
+ function getRecordKind(value) {
122
+ if (!isRecord(value) || !isString(value.kind) || !RECORD_KINDS.has(value.kind)) {
123
+ return null;
124
+ }
125
+ return value.kind;
126
+ }
127
+ function getTaskId(value) {
128
+ return isRecord(value) && isString(value.task_id) ? value.task_id : null;
129
+ }
130
+ function pushIssue(issues, severity, code, path, message) {
131
+ issues.push({ severity, code, path, message });
132
+ }
133
+ function validateString(issues, value, pointer, label, options) {
134
+ if (value === undefined) {
135
+ if (options.required) {
136
+ pushIssue(issues, 'error', 'missing_required_field', pointer, `${label} is required.`);
137
+ }
138
+ return;
139
+ }
140
+ if (!isString(value)) {
141
+ pushIssue(issues, 'error', 'invalid_string', pointer, `${label} must be a string.`);
142
+ return;
143
+ }
144
+ if (options.nonEmpty && value.trim().length === 0) {
145
+ pushIssue(issues, 'error', 'empty_string', pointer, `${label} must not be empty.`);
146
+ }
147
+ if (value.length > MAX_STRING_LENGTH) {
148
+ pushIssue(issues, 'error', 'string_too_long', pointer, `${label} is too long for a restart pointer record.`);
149
+ }
150
+ }
151
+ function validateStringArray(issues, value, pointer, label, options) {
152
+ if (value === undefined) {
153
+ if (options.required) {
154
+ pushIssue(issues, 'error', 'missing_required_field', pointer, `${label} is required.`);
155
+ }
156
+ return;
157
+ }
158
+ if (!Array.isArray(value)) {
159
+ pushIssue(issues, 'error', 'invalid_array', pointer, `${label} must be an array.`);
160
+ return;
161
+ }
162
+ if (options.nonEmpty && value.length === 0) {
163
+ pushIssue(issues, 'error', 'empty_array', pointer, `${label} must include at least one entry.`);
164
+ }
165
+ if (value.length > MAX_ARRAY_ITEMS) {
166
+ pushIssue(issues, 'error', 'array_too_large', pointer, `${label} has too many entries for a restart pointer.`);
167
+ }
168
+ value.forEach((item, index) => {
169
+ validateString(issues, item, `${pointer}[${index}]`, `${label} item`, {
170
+ required: true,
171
+ nonEmpty: true,
172
+ });
173
+ });
174
+ }
175
+ function validateAllowedKeys(issues, record, allowedKeys, pointer) {
176
+ for (const key of Object.keys(record)) {
177
+ if (!allowedKeys.has(key)) {
178
+ pushIssue(issues, 'error', 'unknown_field', `${pointer}.${key}`, `Field is not part of the handoff record contract.`);
179
+ }
180
+ }
181
+ }
182
+ function validateVerificationPlan(issues, value) {
183
+ if (value === undefined) {
184
+ return;
185
+ }
186
+ if (!Array.isArray(value)) {
187
+ pushIssue(issues, 'error', 'invalid_array', '$.verification_plan', 'verification_plan must be an array.');
188
+ return;
189
+ }
190
+ if (value.length > MAX_ARRAY_ITEMS) {
191
+ pushIssue(issues, 'error', 'array_too_large', '$.verification_plan', 'verification_plan has too many entries for a restart pointer.');
192
+ }
193
+ value.forEach((entry, index) => {
194
+ const pointer = `$.verification_plan[${index}]`;
195
+ if (!isRecord(entry)) {
196
+ pushIssue(issues, 'error', 'invalid_object', pointer, 'verification_plan entries must be objects.');
197
+ return;
198
+ }
199
+ validateAllowedKeys(issues, entry, ALLOWED_VERIFICATION_PLAN_KEYS, pointer);
200
+ validateString(issues, entry.intent, `${pointer}.intent`, 'intent', { required: true, nonEmpty: true });
201
+ validateString(issues, entry.reason, `${pointer}.reason`, 'reason', { required: true, nonEmpty: true });
202
+ if (!isString(entry.status) || !VERIFICATION_STATUSES.has(entry.status)) {
203
+ pushIssue(issues, 'error', 'invalid_verification_status', `${pointer}.status`, 'status must be one of planned, run, or skipped.');
204
+ }
205
+ validateString(issues, entry.receipt_path, `${pointer}.receipt_path`, 'receipt_path', {
206
+ required: false,
207
+ nonEmpty: true,
208
+ });
209
+ validateString(issues, entry.skip_reason, `${pointer}.skip_reason`, 'skip_reason', {
210
+ required: false,
211
+ nonEmpty: true,
212
+ });
213
+ if (entry.status === 'skipped' && entry.skip_reason === undefined) {
214
+ pushIssue(issues, 'error', 'missing_skip_reason', `${pointer}.skip_reason`, 'Skipped verification must explain why it was skipped.');
215
+ }
216
+ if (entry.status !== 'run' && entry.receipt_path !== undefined) {
217
+ pushIssue(issues, 'error', 'unrun_verification_receipt_claim', `${pointer}.receipt_path`, 'Only verification entries with status run may include a receipt_path.');
218
+ }
219
+ if (entry.status !== 'skipped' && entry.skip_reason !== undefined) {
220
+ pushIssue(issues, 'warning', 'unused_skip_reason', `${pointer}.skip_reason`, 'skip_reason is meaningful only when status is skipped.');
221
+ }
222
+ });
223
+ }
224
+ function validateCoverage(issues, value) {
225
+ if (value === undefined) {
226
+ return;
227
+ }
228
+ if (!Array.isArray(value)) {
229
+ pushIssue(issues, 'error', 'invalid_array', '$.coverage', 'coverage must be an array.');
230
+ return;
231
+ }
232
+ if (value.length > MAX_ARRAY_ITEMS) {
233
+ pushIssue(issues, 'error', 'array_too_large', '$.coverage', 'coverage has too many entries for a restart pointer.');
234
+ }
235
+ value.forEach((entry, index) => {
236
+ const pointer = `$.coverage[${index}]`;
237
+ if (!isRecord(entry)) {
238
+ pushIssue(issues, 'error', 'invalid_object', pointer, 'coverage entries must be objects.');
239
+ return;
240
+ }
241
+ validateAllowedKeys(issues, entry, ALLOWED_COVERAGE_KEYS, pointer);
242
+ if (!isString(entry.status) || !COVERAGE_STATUSES.has(entry.status)) {
243
+ pushIssue(issues, 'error', 'invalid_coverage_status', `${pointer}.status`, 'coverage status must be one of covered, partial, missing, or blocked.');
244
+ }
245
+ validateString(issues, entry.requirement, `${pointer}.requirement`, 'requirement', {
246
+ required: false,
247
+ nonEmpty: true,
248
+ });
249
+ validateStringArray(issues, entry.evidence, `${pointer}.evidence`, 'evidence', {
250
+ required: false,
251
+ nonEmpty: false,
252
+ });
253
+ validateString(issues, entry.gap, `${pointer}.gap`, 'gap', { required: false, nonEmpty: true });
254
+ if (entry.status === 'covered' && (!Array.isArray(entry.evidence) || entry.evidence.length === 0)) {
255
+ pushIssue(issues, 'warning', 'covered_without_evidence', `${pointer}.evidence`, 'covered entries should name the guard, file, or receipt that supports the claim.');
256
+ }
257
+ });
258
+ }
259
+ function scanForbiddenKeysAndValues(issues, value, pointer, depth = 0) {
260
+ if (depth > MAX_OBJECT_DEPTH) {
261
+ pushIssue(issues, 'error', 'record_too_deep', pointer, 'Handoff records must stay shallow restart pointers.');
262
+ return;
263
+ }
264
+ if (isString(value)) {
265
+ for (const rule of SECRET_VALUE_RULES) {
266
+ if (rule.pattern.test(value)) {
267
+ pushIssue(issues, 'error', rule.code, pointer, rule.message);
268
+ }
269
+ }
270
+ if (/[A-Z]:\\Users\\/u.test(value) || /\/home\/[^/\s]+/u.test(value)) {
271
+ pushIssue(issues, 'warning', 'personal_path_candidate', pointer, 'Value looks like a personal local path; use repository-relative paths when possible.');
272
+ }
273
+ return;
274
+ }
275
+ if (Array.isArray(value)) {
276
+ value.forEach((item, index) => scanForbiddenKeysAndValues(issues, item, `${pointer}[${index}]`, depth + 1));
277
+ return;
278
+ }
279
+ if (!isRecord(value)) {
280
+ return;
281
+ }
282
+ for (const [key, nestedValue] of Object.entries(value)) {
283
+ const nestedPointer = pointer === '$' ? `$.${key}` : `${pointer}.${key}`;
284
+ const normalizedKey = normalizeKey(key);
285
+ for (const rule of FORBIDDEN_KEY_RULES) {
286
+ if (rule.pattern.test(normalizedKey)) {
287
+ pushIssue(issues, 'error', rule.code, nestedPointer, rule.message);
288
+ }
289
+ }
290
+ scanForbiddenKeysAndValues(issues, nestedValue, nestedPointer, depth + 1);
291
+ }
292
+ }
293
+ function validateRecordShape(issues, value) {
294
+ if (!isRecord(value)) {
295
+ pushIssue(issues, 'error', 'invalid_record', '$', 'Handoff record must be a JSON object.');
296
+ return;
297
+ }
298
+ validateAllowedKeys(issues, value, ALLOWED_TOP_LEVEL_KEYS, '$');
299
+ if (value.schema_version !== HANDOFF_SCHEMA_VERSION) {
300
+ pushIssue(issues, 'error', 'invalid_schema_version', '$.schema_version', 'schema_version must be "1".');
301
+ }
302
+ if (!isString(value.kind) || !RECORD_KINDS.has(value.kind)) {
303
+ pushIssue(issues, 'error', 'invalid_kind', '$.kind', 'kind must be work_item or handoff.');
304
+ }
305
+ validateString(issues, value.task_id, '$.task_id', 'task_id', { required: true, nonEmpty: true });
306
+ validateString(issues, value.goal, '$.goal', 'goal', { required: true, nonEmpty: true });
307
+ validateStringArray(issues, value.scope, '$.scope', 'scope', { required: true, nonEmpty: true });
308
+ validateStringArray(issues, value.non_goals, '$.non_goals', 'non_goals', { required: false, nonEmpty: false });
309
+ validateStringArray(issues, value.acceptance_criteria, '$.acceptance_criteria', 'acceptance_criteria', {
310
+ required: true,
311
+ nonEmpty: true,
312
+ });
313
+ validateStringArray(issues, value.source_refs, '$.source_refs', 'source_refs', {
314
+ required: true,
315
+ nonEmpty: true,
316
+ });
317
+ validateStringArray(issues, value.changed_surfaces, '$.changed_surfaces', 'changed_surfaces', {
318
+ required: false,
319
+ nonEmpty: false,
320
+ });
321
+ validateVerificationPlan(issues, value.verification_plan);
322
+ validateCoverage(issues, value.coverage);
323
+ validateStringArray(issues, value.remaining_risks, '$.remaining_risks', 'remaining_risks', {
324
+ required: false,
325
+ nonEmpty: false,
326
+ });
327
+ validateString(issues, value.next_restart_point, '$.next_restart_point', 'next_restart_point', {
328
+ required: true,
329
+ nonEmpty: true,
330
+ });
331
+ }
332
+ export function validateHandoffRecord(value, options) {
333
+ const issues = [];
334
+ validateRecordShape(issues, value);
335
+ scanForbiddenKeysAndValues(issues, value, '$');
336
+ const hasErrors = issues.some((issue) => issue.severity === 'error');
337
+ return {
338
+ schema_version: HANDOFF_SCHEMA_VERSION,
339
+ command: 'handoff_validate',
340
+ ok: !hasErrors,
341
+ mustflow_root: options.mustflowRoot,
342
+ path: options.path,
343
+ record_kind: getRecordKind(value),
344
+ task_id: getTaskId(value),
345
+ summary: getSummary(value),
346
+ issues,
347
+ };
348
+ }
349
+ export function validateHandoffRecordJson(content, options) {
350
+ let parsed;
351
+ try {
352
+ parsed = JSON.parse(content);
353
+ }
354
+ catch (error) {
355
+ const message = error instanceof Error ? error.message : String(error);
356
+ return {
357
+ schema_version: HANDOFF_SCHEMA_VERSION,
358
+ command: 'handoff_validate',
359
+ ok: false,
360
+ mustflow_root: options.mustflowRoot,
361
+ path: options.path,
362
+ record_kind: null,
363
+ task_id: null,
364
+ summary: makeEmptySummary(),
365
+ issues: [
366
+ {
367
+ severity: 'error',
368
+ code: 'invalid_json',
369
+ path: '$',
370
+ message: `Handoff record must be valid JSON: ${message}`,
371
+ },
372
+ ],
373
+ };
374
+ }
375
+ return validateHandoffRecord(parsed, options);
376
+ }
@@ -1,4 +1,12 @@
1
1
  const PUBLIC_JSON_SCHEMA_CONTRACTS = [
2
+ {
3
+ id: 'adapter-compatibility-report',
4
+ schemaFile: 'adapter-compatibility-report.schema.json',
5
+ producer: 'mf adapters status --json',
6
+ packaged: true,
7
+ documented: true,
8
+ installedCommand: ['mf', 'adapters', 'status', '--json'],
9
+ },
2
10
  {
3
11
  id: 'doctor-report',
4
12
  schemaFile: 'doctor-report.schema.json',
@@ -63,6 +71,14 @@ const PUBLIC_JSON_SCHEMA_CONTRACTS = [
63
71
  installedCommand: ['mf', 'line-endings', 'check', '--json'],
64
72
  expectedExitCodes: [0, 1],
65
73
  },
74
+ {
75
+ id: 'handoff-validation-report',
76
+ schemaFile: 'handoff-validation-report.schema.json',
77
+ producer: 'mf handoff validate <path> --json',
78
+ packaged: true,
79
+ documented: true,
80
+ expectedExitCodes: [0, 1],
81
+ },
66
82
  {
67
83
  id: 'version-sources-report',
68
84
  schemaFile: 'version-sources-report.schema.json',
@@ -1,6 +1,7 @@
1
1
  import { mkdirSync, writeFileSync } from 'node:fs';
2
2
  import path from 'node:path';
3
3
  import { DEFAULT_RUN_RECEIPT_TAIL_BYTES } from './retention-policy.js';
4
+ import { redactSecretLikeText } from './secret-redaction.js';
4
5
  const RUN_RECEIPT_SCHEMA_VERSION = '1';
5
6
  const RUN_RECEIPT_DIR = path.join('.mustflow', 'state', 'runs');
6
7
  const LATEST_RUN_RECEIPT = 'latest.json';
@@ -17,22 +18,45 @@ function truncateTextByBytes(text, maxBytes) {
17
18
  truncated: true,
18
19
  };
19
20
  }
20
- function summarizeOutput(output, maxOutputBytes, tailBytes) {
21
+ function recordRedaction(state, field, result) {
22
+ if (!result.redacted) {
23
+ return;
24
+ }
25
+ state.fields.add(field);
26
+ state.count += result.redactionCount;
27
+ for (const kind of result.redactionKinds) {
28
+ state.kinds.add(kind);
29
+ }
30
+ }
31
+ function redactReceiptString(value, field, state) {
32
+ const redaction = redactSecretLikeText(value);
33
+ recordRedaction(state, field, redaction);
34
+ return redaction.text;
35
+ }
36
+ function summarizeOutput(output, maxOutputBytes, tailBytes, field, state) {
21
37
  if (!output) {
22
38
  return {
23
39
  bytes: 0,
24
40
  truncated: false,
25
41
  tail: '',
42
+ redacted: false,
43
+ redaction_count: 0,
44
+ redaction_kinds: [],
26
45
  };
27
46
  }
28
47
  const text = output.toString();
29
48
  const bytes = Buffer.byteLength(text, 'utf8');
30
49
  const tailLimit = Math.min(tailBytes, maxOutputBytes);
31
50
  const tail = truncateTextByBytes(text, tailLimit);
51
+ const redaction = redactSecretLikeText(tail.text);
52
+ recordRedaction(state, `${field}.tail`, redaction);
32
53
  return {
33
54
  bytes,
34
55
  truncated: tail.truncated,
35
- tail: tail.text,
56
+ tail: redaction.text,
57
+ redacted: redaction.redacted,
58
+ redaction_count: redaction.redactionCount,
59
+ redaction_kinds: redaction.redactionKinds,
36
60
  };
37
61
  }
38
62
  function getReceiptRelativePath() {
@@ -42,6 +66,12 @@ export function createRunReceipt(input) {
42
66
  const relativeCwd = path.relative(input.projectRoot, input.cwd);
43
67
  const stdoutTailBytes = input.stdoutTailBytes ?? DEFAULT_RUN_RECEIPT_TAIL_BYTES;
44
68
  const stderrTailBytes = input.stderrTailBytes ?? DEFAULT_RUN_RECEIPT_TAIL_BYTES;
69
+ const redactionState = { fields: new Set(), kinds: new Set(), count: 0 };
70
+ const argv = input.argv?.map((value, index) => redactReceiptString(value, `argv.${index}`, redactionState));
71
+ const cmd = input.cmd ? redactReceiptString(input.cmd, 'cmd', redactionState) : undefined;
72
+ const error = input.error ? redactReceiptString(input.error, 'error', redactionState) : null;
73
+ const stdout = summarizeOutput(input.stdout, input.maxOutputBytes, stdoutTailBytes, 'stdout', redactionState);
74
+ const stderr = summarizeOutput(input.stderr, input.maxOutputBytes, stderrTailBytes, 'stderr', redactionState);
45
75
  return {
46
76
  schema_version: RUN_RECEIPT_SCHEMA_VERSION,
47
77
  command: 'run',
@@ -55,17 +85,26 @@ export function createRunReceipt(input) {
55
85
  lifecycle: input.lifecycle,
56
86
  run_policy: input.runPolicy,
57
87
  mode: input.mode,
58
- argv: input.argv,
59
- cmd: input.cmd,
88
+ argv,
89
+ cmd,
90
+ env_policy: input.envPolicy,
91
+ env_allowlist: input.envAllowlist,
60
92
  timeout_seconds: input.timeoutSeconds,
61
93
  max_output_bytes: input.maxOutputBytes,
62
94
  success_exit_codes: input.successExitCodes,
63
95
  exit_code: input.exitCode,
64
96
  signal: input.signal,
65
- error: input.error,
97
+ error,
66
98
  kill_method: input.killMethod,
67
- stdout: summarizeOutput(input.stdout, input.maxOutputBytes, stdoutTailBytes),
68
- stderr: summarizeOutput(input.stderr, input.maxOutputBytes, stderrTailBytes),
99
+ stdout,
100
+ stderr,
101
+ write_drift: input.writeDrift,
102
+ redaction: {
103
+ redacted: redactionState.count > 0,
104
+ redaction_count: redactionState.count,
105
+ redaction_kinds: [...redactionState.kinds].sort(),
106
+ fields: [...redactionState.fields].sort(),
107
+ },
69
108
  receipt_path: getReceiptRelativePath(),
70
109
  };
71
110
  }
@@ -0,0 +1,180 @@
1
+ import { spawnSync } from 'node:child_process';
2
+ import { lstatSync, readlinkSync, readdirSync } from 'node:fs';
3
+ import path from 'node:path';
4
+ import { normalizeCommandEffects } from './command-effects.js';
5
+ const MAX_SNAPSHOT_FILES = 20_000;
6
+ const MAX_REPORTED_PATHS = 200;
7
+ const EXCLUDED_DIRECTORY_NAMES = new Set(['.git', 'node_modules']);
8
+ const EXCLUDED_RELATIVE_DIRECTORY_PATHS = new Set(['.mustflow/state/runs']);
9
+ function toPosixPath(value) {
10
+ return value.split(path.sep).join('/');
11
+ }
12
+ function normalizeRelativePath(value) {
13
+ return toPosixPath(value).replace(/^\.\/+/u, '').replace(/\/+$/u, '') || '.';
14
+ }
15
+ function pathKey(value) {
16
+ const normalized = normalizeRelativePath(value);
17
+ return process.platform === 'win32' ? normalized.toLowerCase() : normalized;
18
+ }
19
+ function isExcludedDirectory(relativePath, basename) {
20
+ const normalized = normalizeRelativePath(relativePath);
21
+ return EXCLUDED_DIRECTORY_NAMES.has(basename) || EXCLUDED_RELATIVE_DIRECTORY_PATHS.has(normalized);
22
+ }
23
+ function signatureForPath(fullPath) {
24
+ const stat = lstatSync(fullPath);
25
+ if (stat.isSymbolicLink()) {
26
+ return `symlink:${readlinkSync(fullPath)}`;
27
+ }
28
+ const type = stat.isDirectory() ? 'directory' : stat.isFile() ? 'file' : 'other';
29
+ return `${type}:${stat.size}:${stat.mtimeMs}`;
30
+ }
31
+ function collectSnapshotEntries(projectRoot, currentPath, entries) {
32
+ const names = readdirSync(currentPath).sort((left, right) => left.localeCompare(right));
33
+ for (const name of names) {
34
+ const fullPath = path.join(currentPath, name);
35
+ const relativePath = normalizeRelativePath(path.relative(projectRoot, fullPath));
36
+ const stat = lstatSync(fullPath);
37
+ if (stat.isDirectory()) {
38
+ if (isExcludedDirectory(relativePath, name)) {
39
+ continue;
40
+ }
41
+ collectSnapshotEntries(projectRoot, fullPath, entries);
42
+ continue;
43
+ }
44
+ if (entries.size >= MAX_SNAPSHOT_FILES) {
45
+ throw new Error('snapshot_file_limit_exceeded');
46
+ }
47
+ entries.set(relativePath, signatureForPath(fullPath));
48
+ }
49
+ }
50
+ function captureSnapshot(projectRoot) {
51
+ const gitSnapshot = captureGitStatusSnapshot(projectRoot);
52
+ if (gitSnapshot) {
53
+ return gitSnapshot;
54
+ }
55
+ try {
56
+ const entries = new Map();
57
+ collectSnapshotEntries(projectRoot, projectRoot, entries);
58
+ return { ok: true, entries, reason: null };
59
+ }
60
+ catch (error) {
61
+ return {
62
+ ok: false,
63
+ entries: new Map(),
64
+ reason: error instanceof Error && error.message.length > 0 ? error.message : 'snapshot_unavailable',
65
+ };
66
+ }
67
+ }
68
+ function captureGitStatusSnapshot(projectRoot) {
69
+ const result = spawnSync('git', ['-C', projectRoot, 'status', '--porcelain=v1', '-z', '--untracked-files=all'], {
70
+ encoding: 'utf8',
71
+ input: '',
72
+ stdio: ['ignore', 'pipe', 'pipe'],
73
+ windowsHide: true,
74
+ });
75
+ if (result.error || result.status !== 0) {
76
+ return null;
77
+ }
78
+ const entries = new Map();
79
+ const parts = result.stdout.split('\0').filter((part) => part.length > 0);
80
+ for (let index = 0; index < parts.length; index += 1) {
81
+ const entry = parts[index] ?? '';
82
+ const status = entry.slice(0, 2);
83
+ const filePath = normalizeRelativePath(entry.slice(3));
84
+ if (filePath.length === 0) {
85
+ continue;
86
+ }
87
+ entries.set(filePath, `git:${status}`);
88
+ if (status.includes('R') || status.includes('C')) {
89
+ index += 1;
90
+ }
91
+ }
92
+ return {
93
+ ok: true,
94
+ entries,
95
+ reason: null,
96
+ };
97
+ }
98
+ function listDeclaredWritePaths(projectRoot, contract, intentName) {
99
+ const paths = normalizeCommandEffects(projectRoot, contract, intentName)
100
+ .filter((effect) => effect.access === 'write')
101
+ .map((effect) => effect.path);
102
+ return [...new Set(paths.map(normalizeRelativePath))].sort((left, right) => left.localeCompare(right));
103
+ }
104
+ function listObservedChangedPaths(before, after) {
105
+ const paths = new Set([...before.keys(), ...after.keys()]);
106
+ const changed = [];
107
+ for (const filePath of paths) {
108
+ if (before.get(filePath) !== after.get(filePath)) {
109
+ changed.push(filePath);
110
+ }
111
+ }
112
+ return changed.sort((left, right) => left.localeCompare(right));
113
+ }
114
+ function declaredPathCoversObservedPath(declaredPath, observedPath) {
115
+ const declaredKey = pathKey(declaredPath);
116
+ const observedKey = pathKey(observedPath);
117
+ return declaredKey === '.' || observedKey === declaredKey || observedKey.startsWith(`${declaredKey}/`);
118
+ }
119
+ function truncatePaths(paths) {
120
+ if (paths.length <= MAX_REPORTED_PATHS) {
121
+ return { paths, truncated: false };
122
+ }
123
+ return { paths: paths.slice(0, MAX_REPORTED_PATHS), truncated: true };
124
+ }
125
+ export function startRunWriteTracking(projectRoot, contract, intentName) {
126
+ return {
127
+ projectRoot,
128
+ declaredPaths: listDeclaredWritePaths(projectRoot, contract, intentName),
129
+ before: captureSnapshot(projectRoot),
130
+ };
131
+ }
132
+ export function finishRunWriteTracking(tracker) {
133
+ if (!tracker.before.ok) {
134
+ return {
135
+ status: 'unavailable',
136
+ declared_paths: tracker.declaredPaths,
137
+ observed_paths: [],
138
+ declared_observed_paths: [],
139
+ undeclared_paths: [],
140
+ observed_count: 0,
141
+ undeclared_count: 0,
142
+ has_undeclared_changes: false,
143
+ truncated: false,
144
+ reason: tracker.before.reason,
145
+ };
146
+ }
147
+ const after = captureSnapshot(tracker.projectRoot);
148
+ if (!after.ok) {
149
+ return {
150
+ status: 'unavailable',
151
+ declared_paths: tracker.declaredPaths,
152
+ observed_paths: [],
153
+ declared_observed_paths: [],
154
+ undeclared_paths: [],
155
+ observed_count: 0,
156
+ undeclared_count: 0,
157
+ has_undeclared_changes: false,
158
+ truncated: false,
159
+ reason: after.reason,
160
+ };
161
+ }
162
+ const observedPaths = listObservedChangedPaths(tracker.before.entries, after.entries);
163
+ const declaredObservedPaths = observedPaths.filter((observedPath) => tracker.declaredPaths.some((declaredPath) => declaredPathCoversObservedPath(declaredPath, observedPath)));
164
+ const undeclaredPaths = observedPaths.filter((observedPath) => !tracker.declaredPaths.some((declaredPath) => declaredPathCoversObservedPath(declaredPath, observedPath)));
165
+ const observed = truncatePaths(observedPaths);
166
+ const declaredObserved = truncatePaths(declaredObservedPaths);
167
+ const undeclared = truncatePaths(undeclaredPaths);
168
+ return {
169
+ status: 'checked',
170
+ declared_paths: tracker.declaredPaths,
171
+ observed_paths: observed.paths,
172
+ declared_observed_paths: declaredObserved.paths,
173
+ undeclared_paths: undeclared.paths,
174
+ observed_count: observedPaths.length,
175
+ undeclared_count: undeclaredPaths.length,
176
+ has_undeclared_changes: undeclaredPaths.length > 0,
177
+ truncated: observed.truncated || declaredObserved.truncated || undeclared.truncated,
178
+ reason: null,
179
+ };
180
+ }