mustflow 1.18.16 → 1.31.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 (314) hide show
  1. package/README.md +28 -8
  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 +302 -168
  10. package/dist/cli/commands/update.js +91 -61
  11. package/dist/cli/commands/upgrade.js +65 -0
  12. package/dist/cli/commands/verify.js +304 -139
  13. package/dist/cli/i18n/en.js +77 -4
  14. package/dist/cli/i18n/es.js +77 -4
  15. package/dist/cli/i18n/fr.js +77 -4
  16. package/dist/cli/i18n/hi.js +77 -4
  17. package/dist/cli/i18n/ko.js +77 -4
  18. package/dist/cli/i18n/zh.js +77 -4
  19. package/dist/cli/index.js +34 -42
  20. package/dist/cli/lib/command-registry.js +15 -0
  21. package/dist/cli/lib/dashboard-export.js +775 -0
  22. package/dist/cli/lib/dashboard-html.js +1 -1
  23. package/dist/cli/lib/local-index.js +33 -14
  24. package/dist/cli/lib/reporter.js +6 -0
  25. package/dist/cli/lib/run-plan.js +239 -0
  26. package/dist/cli/lib/templates.js +18 -3
  27. package/dist/cli/lib/update-diff-preview.js +163 -0
  28. package/dist/cli/lib/validation.js +132 -1
  29. package/dist/core/adapter-compatibility.js +235 -0
  30. package/dist/core/bounded-output.js +38 -0
  31. package/dist/core/change-classification.js +14 -1
  32. package/dist/core/change-verification.js +246 -5
  33. package/dist/core/check-issues.js +10 -0
  34. package/dist/core/command-contract-validation.js +34 -0
  35. package/dist/core/command-cwd.js +18 -6
  36. package/dist/core/command-effects.js +13 -0
  37. package/dist/core/command-env.js +91 -0
  38. package/dist/core/contract-lint.js +260 -4
  39. package/dist/core/contract-models.js +172 -0
  40. package/dist/core/dashboard-verification.js +10 -0
  41. package/dist/core/doc-review-triage.js +1 -0
  42. package/dist/core/handoff-record.js +376 -0
  43. package/dist/core/public-json-contracts.js +23 -0
  44. package/dist/core/run-performance-history.js +307 -0
  45. package/dist/core/run-profile.js +87 -0
  46. package/dist/core/run-receipt.js +217 -11
  47. package/dist/core/run-write-drift.js +196 -0
  48. package/dist/core/secret-redaction.js +39 -0
  49. package/dist/core/skill-route-alignment.js +90 -0
  50. package/dist/core/source-anchors.js +3 -5
  51. package/dist/core/test-selection.js +224 -0
  52. package/dist/core/verification-decision-graph.js +290 -0
  53. package/dist/core/verification-scheduler.js +96 -2
  54. package/package.json +3 -1
  55. package/schemas/README.md +15 -4
  56. package/schemas/adapter-compatibility-report.schema.json +184 -0
  57. package/schemas/change-verification-report.schema.json +286 -4
  58. package/schemas/commands.schema.json +55 -2
  59. package/schemas/contract-lint-report.schema.json +99 -0
  60. package/schemas/dashboard-export.schema.json +273 -0
  61. package/schemas/explain-report.schema.json +267 -2
  62. package/schemas/handoff-validation-report.schema.json +68 -0
  63. package/schemas/run-receipt.schema.json +183 -1
  64. package/templates/default/common/.mustflow/config/commands.toml +3 -1
  65. package/templates/default/i18n.toml +78 -234
  66. package/templates/default/locales/en/.mustflow/skills/INDEX.md +7 -3
  67. package/templates/default/locales/en/.mustflow/skills/architecture-deepening-review/SKILL.md +154 -0
  68. package/templates/default/locales/en/.mustflow/skills/behavior-preserving-refactor/SKILL.md +8 -3
  69. package/templates/default/locales/en/.mustflow/skills/code-review/SKILL.md +9 -4
  70. package/templates/default/locales/en/.mustflow/skills/date-number-audit/SKILL.md +19 -4
  71. package/templates/default/locales/en/.mustflow/skills/diff-risk-review/SKILL.md +4 -2
  72. package/templates/default/locales/en/.mustflow/skills/external-skill-intake/SKILL.md +141 -0
  73. package/templates/default/locales/en/.mustflow/skills/release-notes-authoring/SKILL.md +143 -0
  74. package/templates/default/locales/en/.mustflow/skills/repro-first-debug/SKILL.md +22 -8
  75. package/templates/default/locales/en/.mustflow/skills/skill-authoring/SKILL.md +3 -3
  76. package/templates/default/locales/en/.mustflow/skills/source-freshness-check/SKILL.md +22 -9
  77. package/templates/default/locales/en/.mustflow/skills/ui-quality-gate/SKILL.md +21 -13
  78. package/templates/default/locales/en/.mustflow/skills/vertical-slice-tdd/SKILL.md +167 -0
  79. package/templates/default/manifest.toml +16 -1
  80. package/templates/default/locales/es/.mustflow/skills/INDEX.md +0 -75
  81. package/templates/default/locales/es/.mustflow/skills/adapter-boundary/SKILL.md +0 -193
  82. package/templates/default/locales/es/.mustflow/skills/artifact-integrity-check/SKILL.md +0 -114
  83. package/templates/default/locales/es/.mustflow/skills/behavior-preserving-refactor/SKILL.md +0 -182
  84. package/templates/default/locales/es/.mustflow/skills/code-review/SKILL.md +0 -115
  85. package/templates/default/locales/es/.mustflow/skills/codebase-orientation/SKILL.md +0 -115
  86. package/templates/default/locales/es/.mustflow/skills/command-pattern/SKILL.md +0 -247
  87. package/templates/default/locales/es/.mustflow/skills/composition-over-inheritance/SKILL.md +0 -176
  88. package/templates/default/locales/es/.mustflow/skills/contract-sync-check/SKILL.md +0 -116
  89. package/templates/default/locales/es/.mustflow/skills/database-change-safety/SKILL.md +0 -155
  90. package/templates/default/locales/es/.mustflow/skills/date-number-audit/SKILL.md +0 -116
  91. package/templates/default/locales/es/.mustflow/skills/dependency-injection/SKILL.md +0 -161
  92. package/templates/default/locales/es/.mustflow/skills/dependency-reality-check/SKILL.md +0 -115
  93. package/templates/default/locales/es/.mustflow/skills/diff-risk-review/SKILL.md +0 -136
  94. package/templates/default/locales/es/.mustflow/skills/docs-prose-review/SKILL.md +0 -119
  95. package/templates/default/locales/es/.mustflow/skills/docs-update/SKILL.md +0 -97
  96. package/templates/default/locales/es/.mustflow/skills/external-prompt-injection-defense/SKILL.md +0 -116
  97. package/templates/default/locales/es/.mustflow/skills/facade-pattern/SKILL.md +0 -210
  98. package/templates/default/locales/es/.mustflow/skills/failure-triage/SKILL.md +0 -97
  99. package/templates/default/locales/es/.mustflow/skills/instruction-conflict-scope-check/SKILL.md +0 -118
  100. package/templates/default/locales/es/.mustflow/skills/line-ending-hygiene/SKILL.md +0 -111
  101. package/templates/default/locales/es/.mustflow/skills/migration-safety-check/SKILL.md +0 -117
  102. package/templates/default/locales/es/.mustflow/skills/multi-agent-work-coordination/SKILL.md +0 -260
  103. package/templates/default/locales/es/.mustflow/skills/null-object-pattern/SKILL.md +0 -196
  104. package/templates/default/locales/es/.mustflow/skills/pattern-scout/SKILL.md +0 -110
  105. package/templates/default/locales/es/.mustflow/skills/performance-budget-check/SKILL.md +0 -121
  106. package/templates/default/locales/es/.mustflow/skills/project-context-authoring/SKILL.md +0 -107
  107. package/templates/default/locales/es/.mustflow/skills/pure-core-imperative-shell/SKILL.md +0 -212
  108. package/templates/default/locales/es/.mustflow/skills/readme-authoring/SKILL.md +0 -115
  109. package/templates/default/locales/es/.mustflow/skills/repo-improvement-loop/SKILL.md +0 -150
  110. package/templates/default/locales/es/.mustflow/skills/repro-first-debug/SKILL.md +0 -112
  111. package/templates/default/locales/es/.mustflow/skills/requirement-regression-guard/SKILL.md +0 -152
  112. package/templates/default/locales/es/.mustflow/skills/result-option/SKILL.md +0 -186
  113. package/templates/default/locales/es/.mustflow/skills/security-privacy-review/SKILL.md +0 -116
  114. package/templates/default/locales/es/.mustflow/skills/security-regression-tests/SKILL.md +0 -131
  115. package/templates/default/locales/es/.mustflow/skills/skill-authoring/SKILL.md +0 -110
  116. package/templates/default/locales/es/.mustflow/skills/source-freshness-check/SKILL.md +0 -111
  117. package/templates/default/locales/es/.mustflow/skills/state-machine-pattern/SKILL.md +0 -214
  118. package/templates/default/locales/es/.mustflow/skills/strategy-pattern/SKILL.md +0 -215
  119. package/templates/default/locales/es/.mustflow/skills/structure-discovery-gate/SKILL.md +0 -159
  120. package/templates/default/locales/es/.mustflow/skills/test-design-guard/SKILL.md +0 -162
  121. package/templates/default/locales/es/.mustflow/skills/test-maintenance/SKILL.md +0 -122
  122. package/templates/default/locales/es/.mustflow/skills/ui-quality-gate/SKILL.md +0 -117
  123. package/templates/default/locales/es/.mustflow/skills/visual-review-artifact/SKILL.md +0 -127
  124. package/templates/default/locales/es/.mustflow/skills/visual-review-artifact/assets/review-template.html +0 -286
  125. package/templates/default/locales/es/.mustflow/skills/visual-review-artifact/resources.toml +0 -7
  126. package/templates/default/locales/es/.mustflow/skills/web-asset-optimization/SKILL.md +0 -108
  127. package/templates/default/locales/fr/.mustflow/skills/INDEX.md +0 -75
  128. package/templates/default/locales/fr/.mustflow/skills/adapter-boundary/SKILL.md +0 -193
  129. package/templates/default/locales/fr/.mustflow/skills/artifact-integrity-check/SKILL.md +0 -114
  130. package/templates/default/locales/fr/.mustflow/skills/behavior-preserving-refactor/SKILL.md +0 -182
  131. package/templates/default/locales/fr/.mustflow/skills/code-review/SKILL.md +0 -115
  132. package/templates/default/locales/fr/.mustflow/skills/codebase-orientation/SKILL.md +0 -115
  133. package/templates/default/locales/fr/.mustflow/skills/command-pattern/SKILL.md +0 -247
  134. package/templates/default/locales/fr/.mustflow/skills/composition-over-inheritance/SKILL.md +0 -176
  135. package/templates/default/locales/fr/.mustflow/skills/contract-sync-check/SKILL.md +0 -116
  136. package/templates/default/locales/fr/.mustflow/skills/database-change-safety/SKILL.md +0 -155
  137. package/templates/default/locales/fr/.mustflow/skills/date-number-audit/SKILL.md +0 -116
  138. package/templates/default/locales/fr/.mustflow/skills/dependency-injection/SKILL.md +0 -161
  139. package/templates/default/locales/fr/.mustflow/skills/dependency-reality-check/SKILL.md +0 -115
  140. package/templates/default/locales/fr/.mustflow/skills/diff-risk-review/SKILL.md +0 -136
  141. package/templates/default/locales/fr/.mustflow/skills/docs-prose-review/SKILL.md +0 -119
  142. package/templates/default/locales/fr/.mustflow/skills/docs-update/SKILL.md +0 -97
  143. package/templates/default/locales/fr/.mustflow/skills/external-prompt-injection-defense/SKILL.md +0 -116
  144. package/templates/default/locales/fr/.mustflow/skills/facade-pattern/SKILL.md +0 -210
  145. package/templates/default/locales/fr/.mustflow/skills/failure-triage/SKILL.md +0 -97
  146. package/templates/default/locales/fr/.mustflow/skills/instruction-conflict-scope-check/SKILL.md +0 -118
  147. package/templates/default/locales/fr/.mustflow/skills/line-ending-hygiene/SKILL.md +0 -111
  148. package/templates/default/locales/fr/.mustflow/skills/migration-safety-check/SKILL.md +0 -117
  149. package/templates/default/locales/fr/.mustflow/skills/multi-agent-work-coordination/SKILL.md +0 -260
  150. package/templates/default/locales/fr/.mustflow/skills/null-object-pattern/SKILL.md +0 -196
  151. package/templates/default/locales/fr/.mustflow/skills/pattern-scout/SKILL.md +0 -110
  152. package/templates/default/locales/fr/.mustflow/skills/performance-budget-check/SKILL.md +0 -121
  153. package/templates/default/locales/fr/.mustflow/skills/project-context-authoring/SKILL.md +0 -107
  154. package/templates/default/locales/fr/.mustflow/skills/pure-core-imperative-shell/SKILL.md +0 -212
  155. package/templates/default/locales/fr/.mustflow/skills/readme-authoring/SKILL.md +0 -115
  156. package/templates/default/locales/fr/.mustflow/skills/repo-improvement-loop/SKILL.md +0 -150
  157. package/templates/default/locales/fr/.mustflow/skills/repro-first-debug/SKILL.md +0 -112
  158. package/templates/default/locales/fr/.mustflow/skills/requirement-regression-guard/SKILL.md +0 -152
  159. package/templates/default/locales/fr/.mustflow/skills/result-option/SKILL.md +0 -186
  160. package/templates/default/locales/fr/.mustflow/skills/security-privacy-review/SKILL.md +0 -116
  161. package/templates/default/locales/fr/.mustflow/skills/security-regression-tests/SKILL.md +0 -131
  162. package/templates/default/locales/fr/.mustflow/skills/skill-authoring/SKILL.md +0 -110
  163. package/templates/default/locales/fr/.mustflow/skills/source-freshness-check/SKILL.md +0 -111
  164. package/templates/default/locales/fr/.mustflow/skills/state-machine-pattern/SKILL.md +0 -214
  165. package/templates/default/locales/fr/.mustflow/skills/strategy-pattern/SKILL.md +0 -215
  166. package/templates/default/locales/fr/.mustflow/skills/structure-discovery-gate/SKILL.md +0 -159
  167. package/templates/default/locales/fr/.mustflow/skills/test-design-guard/SKILL.md +0 -162
  168. package/templates/default/locales/fr/.mustflow/skills/test-maintenance/SKILL.md +0 -122
  169. package/templates/default/locales/fr/.mustflow/skills/ui-quality-gate/SKILL.md +0 -117
  170. package/templates/default/locales/fr/.mustflow/skills/visual-review-artifact/SKILL.md +0 -127
  171. package/templates/default/locales/fr/.mustflow/skills/visual-review-artifact/assets/review-template.html +0 -286
  172. package/templates/default/locales/fr/.mustflow/skills/visual-review-artifact/resources.toml +0 -7
  173. package/templates/default/locales/fr/.mustflow/skills/web-asset-optimization/SKILL.md +0 -108
  174. package/templates/default/locales/hi/.mustflow/skills/INDEX.md +0 -75
  175. package/templates/default/locales/hi/.mustflow/skills/adapter-boundary/SKILL.md +0 -193
  176. package/templates/default/locales/hi/.mustflow/skills/artifact-integrity-check/SKILL.md +0 -114
  177. package/templates/default/locales/hi/.mustflow/skills/behavior-preserving-refactor/SKILL.md +0 -182
  178. package/templates/default/locales/hi/.mustflow/skills/code-review/SKILL.md +0 -115
  179. package/templates/default/locales/hi/.mustflow/skills/codebase-orientation/SKILL.md +0 -115
  180. package/templates/default/locales/hi/.mustflow/skills/command-pattern/SKILL.md +0 -247
  181. package/templates/default/locales/hi/.mustflow/skills/composition-over-inheritance/SKILL.md +0 -176
  182. package/templates/default/locales/hi/.mustflow/skills/contract-sync-check/SKILL.md +0 -116
  183. package/templates/default/locales/hi/.mustflow/skills/database-change-safety/SKILL.md +0 -155
  184. package/templates/default/locales/hi/.mustflow/skills/date-number-audit/SKILL.md +0 -116
  185. package/templates/default/locales/hi/.mustflow/skills/dependency-injection/SKILL.md +0 -161
  186. package/templates/default/locales/hi/.mustflow/skills/dependency-reality-check/SKILL.md +0 -115
  187. package/templates/default/locales/hi/.mustflow/skills/diff-risk-review/SKILL.md +0 -136
  188. package/templates/default/locales/hi/.mustflow/skills/docs-prose-review/SKILL.md +0 -119
  189. package/templates/default/locales/hi/.mustflow/skills/docs-update/SKILL.md +0 -97
  190. package/templates/default/locales/hi/.mustflow/skills/external-prompt-injection-defense/SKILL.md +0 -116
  191. package/templates/default/locales/hi/.mustflow/skills/facade-pattern/SKILL.md +0 -210
  192. package/templates/default/locales/hi/.mustflow/skills/failure-triage/SKILL.md +0 -97
  193. package/templates/default/locales/hi/.mustflow/skills/instruction-conflict-scope-check/SKILL.md +0 -118
  194. package/templates/default/locales/hi/.mustflow/skills/line-ending-hygiene/SKILL.md +0 -111
  195. package/templates/default/locales/hi/.mustflow/skills/migration-safety-check/SKILL.md +0 -117
  196. package/templates/default/locales/hi/.mustflow/skills/multi-agent-work-coordination/SKILL.md +0 -260
  197. package/templates/default/locales/hi/.mustflow/skills/null-object-pattern/SKILL.md +0 -196
  198. package/templates/default/locales/hi/.mustflow/skills/pattern-scout/SKILL.md +0 -110
  199. package/templates/default/locales/hi/.mustflow/skills/performance-budget-check/SKILL.md +0 -121
  200. package/templates/default/locales/hi/.mustflow/skills/project-context-authoring/SKILL.md +0 -107
  201. package/templates/default/locales/hi/.mustflow/skills/pure-core-imperative-shell/SKILL.md +0 -212
  202. package/templates/default/locales/hi/.mustflow/skills/readme-authoring/SKILL.md +0 -115
  203. package/templates/default/locales/hi/.mustflow/skills/repo-improvement-loop/SKILL.md +0 -150
  204. package/templates/default/locales/hi/.mustflow/skills/repro-first-debug/SKILL.md +0 -112
  205. package/templates/default/locales/hi/.mustflow/skills/requirement-regression-guard/SKILL.md +0 -152
  206. package/templates/default/locales/hi/.mustflow/skills/result-option/SKILL.md +0 -186
  207. package/templates/default/locales/hi/.mustflow/skills/security-privacy-review/SKILL.md +0 -116
  208. package/templates/default/locales/hi/.mustflow/skills/security-regression-tests/SKILL.md +0 -131
  209. package/templates/default/locales/hi/.mustflow/skills/skill-authoring/SKILL.md +0 -110
  210. package/templates/default/locales/hi/.mustflow/skills/source-freshness-check/SKILL.md +0 -111
  211. package/templates/default/locales/hi/.mustflow/skills/state-machine-pattern/SKILL.md +0 -214
  212. package/templates/default/locales/hi/.mustflow/skills/strategy-pattern/SKILL.md +0 -215
  213. package/templates/default/locales/hi/.mustflow/skills/structure-discovery-gate/SKILL.md +0 -159
  214. package/templates/default/locales/hi/.mustflow/skills/test-design-guard/SKILL.md +0 -162
  215. package/templates/default/locales/hi/.mustflow/skills/test-maintenance/SKILL.md +0 -122
  216. package/templates/default/locales/hi/.mustflow/skills/ui-quality-gate/SKILL.md +0 -117
  217. package/templates/default/locales/hi/.mustflow/skills/visual-review-artifact/SKILL.md +0 -127
  218. package/templates/default/locales/hi/.mustflow/skills/visual-review-artifact/assets/review-template.html +0 -286
  219. package/templates/default/locales/hi/.mustflow/skills/visual-review-artifact/resources.toml +0 -7
  220. package/templates/default/locales/hi/.mustflow/skills/web-asset-optimization/SKILL.md +0 -108
  221. package/templates/default/locales/ko/.mustflow/skills/INDEX.md +0 -80
  222. package/templates/default/locales/ko/.mustflow/skills/adapter-boundary/SKILL.md +0 -193
  223. package/templates/default/locales/ko/.mustflow/skills/artifact-integrity-check/SKILL.md +0 -114
  224. package/templates/default/locales/ko/.mustflow/skills/behavior-preserving-refactor/SKILL.md +0 -182
  225. package/templates/default/locales/ko/.mustflow/skills/code-review/SKILL.md +0 -118
  226. package/templates/default/locales/ko/.mustflow/skills/codebase-orientation/SKILL.md +0 -115
  227. package/templates/default/locales/ko/.mustflow/skills/command-pattern/SKILL.md +0 -247
  228. package/templates/default/locales/ko/.mustflow/skills/composition-over-inheritance/SKILL.md +0 -176
  229. package/templates/default/locales/ko/.mustflow/skills/contract-sync-check/SKILL.md +0 -116
  230. package/templates/default/locales/ko/.mustflow/skills/database-change-safety/SKILL.md +0 -155
  231. package/templates/default/locales/ko/.mustflow/skills/date-number-audit/SKILL.md +0 -116
  232. package/templates/default/locales/ko/.mustflow/skills/dependency-injection/SKILL.md +0 -161
  233. package/templates/default/locales/ko/.mustflow/skills/dependency-reality-check/SKILL.md +0 -115
  234. package/templates/default/locales/ko/.mustflow/skills/diff-risk-review/SKILL.md +0 -136
  235. package/templates/default/locales/ko/.mustflow/skills/docs-prose-review/SKILL.md +0 -119
  236. package/templates/default/locales/ko/.mustflow/skills/docs-update/SKILL.md +0 -107
  237. package/templates/default/locales/ko/.mustflow/skills/external-prompt-injection-defense/SKILL.md +0 -116
  238. package/templates/default/locales/ko/.mustflow/skills/facade-pattern/SKILL.md +0 -210
  239. package/templates/default/locales/ko/.mustflow/skills/failure-triage/SKILL.md +0 -119
  240. package/templates/default/locales/ko/.mustflow/skills/instruction-conflict-scope-check/SKILL.md +0 -118
  241. package/templates/default/locales/ko/.mustflow/skills/line-ending-hygiene/SKILL.md +0 -111
  242. package/templates/default/locales/ko/.mustflow/skills/migration-safety-check/SKILL.md +0 -117
  243. package/templates/default/locales/ko/.mustflow/skills/multi-agent-work-coordination/SKILL.md +0 -259
  244. package/templates/default/locales/ko/.mustflow/skills/null-object-pattern/SKILL.md +0 -196
  245. package/templates/default/locales/ko/.mustflow/skills/pattern-scout/SKILL.md +0 -110
  246. package/templates/default/locales/ko/.mustflow/skills/performance-budget-check/SKILL.md +0 -121
  247. package/templates/default/locales/ko/.mustflow/skills/project-context-authoring/SKILL.md +0 -107
  248. package/templates/default/locales/ko/.mustflow/skills/pure-core-imperative-shell/SKILL.md +0 -212
  249. package/templates/default/locales/ko/.mustflow/skills/readme-authoring/SKILL.md +0 -115
  250. package/templates/default/locales/ko/.mustflow/skills/repo-improvement-loop/SKILL.md +0 -150
  251. package/templates/default/locales/ko/.mustflow/skills/repro-first-debug/SKILL.md +0 -112
  252. package/templates/default/locales/ko/.mustflow/skills/requirement-regression-guard/SKILL.md +0 -152
  253. package/templates/default/locales/ko/.mustflow/skills/result-option/SKILL.md +0 -186
  254. package/templates/default/locales/ko/.mustflow/skills/security-privacy-review/SKILL.md +0 -116
  255. package/templates/default/locales/ko/.mustflow/skills/security-regression-tests/SKILL.md +0 -131
  256. package/templates/default/locales/ko/.mustflow/skills/skill-authoring/SKILL.md +0 -110
  257. package/templates/default/locales/ko/.mustflow/skills/source-freshness-check/SKILL.md +0 -111
  258. package/templates/default/locales/ko/.mustflow/skills/state-machine-pattern/SKILL.md +0 -214
  259. package/templates/default/locales/ko/.mustflow/skills/strategy-pattern/SKILL.md +0 -215
  260. package/templates/default/locales/ko/.mustflow/skills/structure-discovery-gate/SKILL.md +0 -159
  261. package/templates/default/locales/ko/.mustflow/skills/test-design-guard/SKILL.md +0 -162
  262. package/templates/default/locales/ko/.mustflow/skills/test-maintenance/SKILL.md +0 -130
  263. package/templates/default/locales/ko/.mustflow/skills/ui-quality-gate/SKILL.md +0 -117
  264. package/templates/default/locales/ko/.mustflow/skills/visual-review-artifact/SKILL.md +0 -127
  265. package/templates/default/locales/ko/.mustflow/skills/visual-review-artifact/assets/review-template.html +0 -286
  266. package/templates/default/locales/ko/.mustflow/skills/visual-review-artifact/resources.toml +0 -7
  267. package/templates/default/locales/ko/.mustflow/skills/web-asset-optimization/SKILL.md +0 -108
  268. package/templates/default/locales/zh/.mustflow/skills/INDEX.md +0 -74
  269. package/templates/default/locales/zh/.mustflow/skills/adapter-boundary/SKILL.md +0 -193
  270. package/templates/default/locales/zh/.mustflow/skills/artifact-integrity-check/SKILL.md +0 -114
  271. package/templates/default/locales/zh/.mustflow/skills/behavior-preserving-refactor/SKILL.md +0 -182
  272. package/templates/default/locales/zh/.mustflow/skills/code-review/SKILL.md +0 -115
  273. package/templates/default/locales/zh/.mustflow/skills/codebase-orientation/SKILL.md +0 -115
  274. package/templates/default/locales/zh/.mustflow/skills/command-pattern/SKILL.md +0 -247
  275. package/templates/default/locales/zh/.mustflow/skills/composition-over-inheritance/SKILL.md +0 -176
  276. package/templates/default/locales/zh/.mustflow/skills/contract-sync-check/SKILL.md +0 -116
  277. package/templates/default/locales/zh/.mustflow/skills/database-change-safety/SKILL.md +0 -155
  278. package/templates/default/locales/zh/.mustflow/skills/date-number-audit/SKILL.md +0 -116
  279. package/templates/default/locales/zh/.mustflow/skills/dependency-injection/SKILL.md +0 -161
  280. package/templates/default/locales/zh/.mustflow/skills/dependency-reality-check/SKILL.md +0 -115
  281. package/templates/default/locales/zh/.mustflow/skills/diff-risk-review/SKILL.md +0 -136
  282. package/templates/default/locales/zh/.mustflow/skills/docs-prose-review/SKILL.md +0 -119
  283. package/templates/default/locales/zh/.mustflow/skills/docs-update/SKILL.md +0 -97
  284. package/templates/default/locales/zh/.mustflow/skills/external-prompt-injection-defense/SKILL.md +0 -116
  285. package/templates/default/locales/zh/.mustflow/skills/facade-pattern/SKILL.md +0 -210
  286. package/templates/default/locales/zh/.mustflow/skills/failure-triage/SKILL.md +0 -96
  287. package/templates/default/locales/zh/.mustflow/skills/instruction-conflict-scope-check/SKILL.md +0 -118
  288. package/templates/default/locales/zh/.mustflow/skills/line-ending-hygiene/SKILL.md +0 -111
  289. package/templates/default/locales/zh/.mustflow/skills/migration-safety-check/SKILL.md +0 -117
  290. package/templates/default/locales/zh/.mustflow/skills/multi-agent-work-coordination/SKILL.md +0 -260
  291. package/templates/default/locales/zh/.mustflow/skills/null-object-pattern/SKILL.md +0 -196
  292. package/templates/default/locales/zh/.mustflow/skills/pattern-scout/SKILL.md +0 -110
  293. package/templates/default/locales/zh/.mustflow/skills/performance-budget-check/SKILL.md +0 -121
  294. package/templates/default/locales/zh/.mustflow/skills/project-context-authoring/SKILL.md +0 -107
  295. package/templates/default/locales/zh/.mustflow/skills/pure-core-imperative-shell/SKILL.md +0 -212
  296. package/templates/default/locales/zh/.mustflow/skills/readme-authoring/SKILL.md +0 -115
  297. package/templates/default/locales/zh/.mustflow/skills/repo-improvement-loop/SKILL.md +0 -150
  298. package/templates/default/locales/zh/.mustflow/skills/repro-first-debug/SKILL.md +0 -112
  299. package/templates/default/locales/zh/.mustflow/skills/requirement-regression-guard/SKILL.md +0 -152
  300. package/templates/default/locales/zh/.mustflow/skills/result-option/SKILL.md +0 -186
  301. package/templates/default/locales/zh/.mustflow/skills/security-privacy-review/SKILL.md +0 -116
  302. package/templates/default/locales/zh/.mustflow/skills/security-regression-tests/SKILL.md +0 -131
  303. package/templates/default/locales/zh/.mustflow/skills/skill-authoring/SKILL.md +0 -110
  304. package/templates/default/locales/zh/.mustflow/skills/source-freshness-check/SKILL.md +0 -111
  305. package/templates/default/locales/zh/.mustflow/skills/state-machine-pattern/SKILL.md +0 -214
  306. package/templates/default/locales/zh/.mustflow/skills/strategy-pattern/SKILL.md +0 -215
  307. package/templates/default/locales/zh/.mustflow/skills/structure-discovery-gate/SKILL.md +0 -159
  308. package/templates/default/locales/zh/.mustflow/skills/test-design-guard/SKILL.md +0 -162
  309. package/templates/default/locales/zh/.mustflow/skills/test-maintenance/SKILL.md +0 -122
  310. package/templates/default/locales/zh/.mustflow/skills/ui-quality-gate/SKILL.md +0 -117
  311. package/templates/default/locales/zh/.mustflow/skills/visual-review-artifact/SKILL.md +0 -127
  312. package/templates/default/locales/zh/.mustflow/skills/visual-review-artifact/assets/review-template.html +0 -286
  313. package/templates/default/locales/zh/.mustflow/skills/visual-review-artifact/resources.toml +0 -7
  314. package/templates/default/locales/zh/.mustflow/skills/web-asset-optimization/SKILL.md +0 -108
@@ -1078,7 +1078,7 @@ function renderVerificationPanel() {
1078
1078
  if (!entry) continue;
1079
1079
  const effects = document.createElement("div");
1080
1080
  effects.className = "verification-files";
1081
- effects.textContent = message("dashboard.verification.effects") + ": " + entry.effects.map((effect) => effect.mode + " " + effect.path + " [" + effect.lock + "]").join(", ");
1081
+ effects.textContent = message("dashboard.verification.effects") + ": " + entry.effects.map((effect) => effect.mode + " " + (effect.path || effect.lock) + " [" + effect.lock + "]").join(", ");
1082
1082
  details.appendChild(effects);
1083
1083
  if (entry.conflicts.length > 0) {
1084
1084
  const conflicts = document.createElement("div");
@@ -8,12 +8,16 @@ import { readTomlFile } from './toml.js';
8
8
  import { collectSourceAnchorIndexRecords, } from '../../core/source-anchor-status.js';
9
9
  import { normalizeCommandEffects } from '../../core/command-effects.js';
10
10
  import { listChangeClassificationRuleDescriptors } from '../../core/change-classification.js';
11
- const LOCAL_INDEX_SCHEMA_VERSION = '12';
11
+ const LOCAL_INDEX_SCHEMA_VERSION = '13';
12
12
  const LOCAL_INDEX_PARSER_VERSION = '1';
13
13
  const DEFAULT_DATABASE_RELATIVE_PATH = '.mustflow/cache/mustflow.sqlite';
14
14
  const LOCAL_INDEX_CONTENT_MODE = 'metadata_and_snippets';
15
15
  const LOCAL_INDEX_STORE_FULL_CONTENT = false;
16
16
  const MAX_SNIPPET_BYTES_PER_DOCUMENT = 2048;
17
+ const MAX_SEARCH_MATCH_SNIPPET_CHARS = 240;
18
+ const SEARCH_MATCH_CONTEXT_BEFORE_CHARS = 48;
19
+ const SEARCH_MATCH_CONTEXT_AFTER_CHARS = 96;
20
+ const SEARCH_MATCH_TRUNCATION_MARKER = '...';
17
21
  const SEARCH_NGRAM_MIN_LENGTH = 2;
18
22
  const SEARCH_NGRAM_MAX_LENGTH = 3;
19
23
  const SEARCH_BACKEND_FTS5 = 'fts5';
@@ -447,6 +451,9 @@ function splitIndexedList(value) {
447
451
  function createCommandEffectGraphStatus(databasePath, status, stalePaths = []) {
448
452
  return {
449
453
  source: 'local_index',
454
+ authority: 'explanation_only',
455
+ commandAuthority: '.mustflow/config/commands.toml',
456
+ grantsCommandAuthority: false,
450
457
  status,
451
458
  databasePath,
452
459
  indexFresh: status === 'fresh',
@@ -628,16 +635,22 @@ function getMatchSnippet(fields, query) {
628
635
  if (start === -1) {
629
636
  const [firstGram] = buildSearchNgrams([query]).filter((gram) => lower.includes(gram));
630
637
  if (!firstGram) {
631
- return normalized.slice(0, 160);
638
+ return truncateSearchMatchSnippet(normalized);
632
639
  }
633
640
  start = lower.indexOf(firstGram);
634
641
  matchLength = firstGram.length;
635
642
  }
636
- const from = Math.max(0, start - 48);
637
- const to = Math.min(normalized.length, start + matchLength + 96);
638
- const prefix = from > 0 ? '...' : '';
639
- const suffix = to < normalized.length ? '...' : '';
640
- return `${prefix}${normalized.slice(from, to)}${suffix}`;
643
+ const from = Math.max(0, start - SEARCH_MATCH_CONTEXT_BEFORE_CHARS);
644
+ const to = Math.min(normalized.length, start + matchLength + SEARCH_MATCH_CONTEXT_AFTER_CHARS);
645
+ const prefix = from > 0 ? SEARCH_MATCH_TRUNCATION_MARKER : '';
646
+ const suffix = to < normalized.length ? SEARCH_MATCH_TRUNCATION_MARKER : '';
647
+ return truncateSearchMatchSnippet(`${prefix}${normalized.slice(from, to)}${suffix}`);
648
+ }
649
+ function truncateSearchMatchSnippet(value) {
650
+ if (value.length <= MAX_SEARCH_MATCH_SNIPPET_CHARS) {
651
+ return value;
652
+ }
653
+ return `${value.slice(0, MAX_SEARCH_MATCH_SNIPPET_CHARS - SEARCH_MATCH_TRUNCATION_MARKER.length)}${SEARCH_MATCH_TRUNCATION_MARKER}`;
641
654
  }
642
655
  function scoreMatch(primaryFields, secondaryFields, query) {
643
656
  const lowerQuery = query.toLowerCase();
@@ -739,10 +752,9 @@ CREATE TABLE command_effects (
739
752
  source TEXT NOT NULL,
740
753
  access TEXT NOT NULL,
741
754
  mode TEXT NOT NULL,
742
- path TEXT NOT NULL,
755
+ path TEXT,
743
756
  lock TEXT NOT NULL,
744
- concurrency TEXT NOT NULL,
745
- PRIMARY KEY (intent, source, access, mode, path, lock, concurrency)
757
+ concurrency TEXT NOT NULL
746
758
  );
747
759
 
748
760
  CREATE VIEW command_write_locks AS
@@ -1001,7 +1013,7 @@ function populateSearchTables(database, capabilities, documents, skills, skillRo
1001
1013
  }
1002
1014
  for (const intent of commandIntents) {
1003
1015
  const effects = intent.effects
1004
- .flatMap((effect) => [effect.lock, effect.path, effect.mode, effect.access, effect.concurrency])
1016
+ .flatMap((effect) => [effect.lock, effect.path ?? '', effect.mode, effect.access, effect.concurrency])
1005
1017
  .join(' ');
1006
1018
  insertSearchNgrams(database, 'command_intent', intent.name, [intent.name, intent.status, intent.lifecycle ?? '', intent.runPolicy ?? '', intent.description ?? '', effects], 'command_intent');
1007
1019
  if (capabilities.backend === SEARCH_BACKEND_FTS5) {
@@ -1110,7 +1122,9 @@ function populateDatabase(database, capabilities, documents, skills, skillRoutes
1110
1122
  insertDocumentTerm(database, '.mustflow/config/commands.toml', intent.description, 'command_description');
1111
1123
  for (const effect of intent.effects) {
1112
1124
  database.run('INSERT INTO command_effects (intent, source, access, mode, path, lock, concurrency) VALUES (?, ?, ?, ?, ?, ?, ?)', [effect.intent, effect.source, effect.access, effect.mode, effect.path, effect.lock, effect.concurrency]);
1113
- insertDocumentTerm(database, '.mustflow/config/commands.toml', effect.path, 'command_effect_path');
1125
+ if (effect.path !== null) {
1126
+ insertDocumentTerm(database, '.mustflow/config/commands.toml', effect.path, 'command_effect_path');
1127
+ }
1114
1128
  insertDocumentTerm(database, '.mustflow/config/commands.toml', effect.lock, 'command_effect_lock');
1115
1129
  insertDocumentTerm(database, '.mustflow/config/commands.toml', effect.mode, 'command_effect_mode');
1116
1130
  }
@@ -1397,6 +1411,9 @@ ORDER BY lock, left_intent, right_intent
1397
1411
  `, [intent, intent]).map((row) => mapCommandLockConflict(row, intent));
1398
1412
  return {
1399
1413
  source: 'local_index',
1414
+ authority: 'explanation_only',
1415
+ commandAuthority: '.mustflow/config/commands.toml',
1416
+ grantsCommandAuthority: false,
1400
1417
  status: 'fresh',
1401
1418
  databasePath,
1402
1419
  indexFresh: true,
@@ -1608,7 +1625,7 @@ function getCommandEffects(database, intent) {
1608
1625
  source: toSearchString(row.source),
1609
1626
  access: toSearchString(row.access),
1610
1627
  mode: toSearchString(row.mode),
1611
- path: toSearchString(row.path),
1628
+ path: row.path === null || row.path === undefined ? null : toSearchString(row.path),
1612
1629
  lock: toSearchString(row.lock),
1613
1630
  concurrency: toSearchString(row.concurrency),
1614
1631
  }));
@@ -1810,7 +1827,9 @@ export async function searchLocalIndex(projectRoot, query, options = {}) {
1810
1827
  const description = toSearchString(row.description);
1811
1828
  const effects = getCommandEffects(database, name);
1812
1829
  const effectLocks = [...new Set(effects.map((effect) => effect.lock))].sort((left, right) => left.localeCompare(right));
1813
- const effectPaths = [...new Set(effects.map((effect) => effect.path))].sort((left, right) => left.localeCompare(right));
1830
+ const effectPaths = [
1831
+ ...new Set(effects.map((effect) => effect.path).filter((effectPath) => effectPath !== null)),
1832
+ ].sort((left, right) => left.localeCompare(right));
1814
1833
  const effectModes = [...new Set(effects.map((effect) => effect.mode))].sort((left, right) => left.localeCompare(right));
1815
1834
  const primaryFields = [name];
1816
1835
  const secondaryFields = [status, lifecycle, runPolicy, description, ...effectLocks, ...effectPaths, ...effectModes];
@@ -5,4 +5,10 @@ export const consoleReporter = {
5
5
  stderr(message) {
6
6
  console.error(message);
7
7
  },
8
+ writeStdout(chunk) {
9
+ process.stdout.write(chunk);
10
+ },
11
+ writeStderr(chunk) {
12
+ process.stderr.write(chunk);
13
+ },
8
14
  };
@@ -0,0 +1,239 @@
1
+ import path from 'node:path';
2
+ import { isMustflowBinName } from '../../core/command-classification.js';
3
+ import { resolveSafeProjectCwd } from '../../core/command-cwd.js';
4
+ import { resolveCommandEnv } from '../../core/command-env.js';
5
+ import { evaluateCommandIntentEligibility, } from '../../core/command-intent-eligibility.js';
6
+ import { isRecord, readPositiveInteger, readString, readStringArray, } from '../../core/config-loading.js';
7
+ function getSuccessExitCodes(intent) {
8
+ const value = intent.success_exit_codes;
9
+ if (!Array.isArray(value) || value.length === 0 || value.some((entry) => !Number.isInteger(entry))) {
10
+ return [0];
11
+ }
12
+ return value.map(Number);
13
+ }
14
+ function readBoolean(intent, key) {
15
+ const value = intent[key];
16
+ return typeof value === 'boolean' ? value : undefined;
17
+ }
18
+ function readArray(intent, key) {
19
+ const value = intent[key];
20
+ return Array.isArray(value) ? value : undefined;
21
+ }
22
+ function toPosixPath(value) {
23
+ return value.split(path.sep).join('/');
24
+ }
25
+ function getRelativeProjectPath(projectRoot, targetPath) {
26
+ const relativePath = path.relative(projectRoot, targetPath);
27
+ return relativePath.length > 0 ? toPosixPath(relativePath) : '.';
28
+ }
29
+ function normalizeTestTargets(values) {
30
+ return [
31
+ ...new Set((values ?? [])
32
+ .map((value) => value.trim().replace(/\\/g, '/'))
33
+ .filter((value) => value.length > 0 && !path.posix.isAbsolute(value) && !path.win32.isAbsolute(value))
34
+ .filter((value) => value.split('/').every((segment) => segment.length > 0 && segment !== '.' && segment !== '..'))),
35
+ ].sort((left, right) => left.localeCompare(right));
36
+ }
37
+ function commandAcceptsTestTargets(intent) {
38
+ return isRecord(intent.selection) && intent.selection.accepts_test_targets === true;
39
+ }
40
+ function shouldUseShellForArgvExecutable(executablePath) {
41
+ return process.platform === 'win32' && executablePath.toLowerCase().endsWith('.cmd');
42
+ }
43
+ export function isMustflowBuiltinIntent(intent) {
44
+ return readString(intent, 'kind') === 'mustflow_builtin';
45
+ }
46
+ function resolveCurrentCliEntrypoint() {
47
+ const entrypoint = process.argv[1];
48
+ return entrypoint ? path.resolve(entrypoint) : undefined;
49
+ }
50
+ function resolveArgvCommand(intent, commandArgv) {
51
+ const [command = '', ...args] = commandArgv;
52
+ if (isMustflowBuiltinIntent(intent) && isMustflowBinName(command)) {
53
+ const entrypoint = resolveCurrentCliEntrypoint();
54
+ if (entrypoint) {
55
+ return {
56
+ executable: process.execPath,
57
+ args: [entrypoint, ...args],
58
+ shell: false,
59
+ };
60
+ }
61
+ }
62
+ return {
63
+ executable: command,
64
+ args,
65
+ shell: shouldUseShellForArgvExecutable(command),
66
+ };
67
+ }
68
+ function getRunPlanMode(commandArgv, intent) {
69
+ if (commandArgv) {
70
+ return 'argv';
71
+ }
72
+ return intent.mode === 'shell' ? 'shell' : null;
73
+ }
74
+ function readRunIntentMetadata(contract, intent) {
75
+ const configuredCwd = readString(intent, 'cwd') ?? readString(contract.defaults, 'default_cwd') ?? '.';
76
+ const commandArgv = readStringArray(intent, 'argv');
77
+ const shellCommand = intent.mode === 'shell' ? readString(intent, 'cmd') : undefined;
78
+ const env = resolveCommandEnv(contract, intent);
79
+ return {
80
+ intentStatus: readString(intent, 'status') ?? 'unknown',
81
+ lifecycle: readString(intent, 'lifecycle') ?? null,
82
+ runPolicy: readString(intent, 'run_policy') ?? null,
83
+ kind: readString(intent, 'kind') ?? null,
84
+ configuredCwd,
85
+ timeoutSeconds: readPositiveInteger(intent, 'timeout_seconds') ?? null,
86
+ maxOutputBytes: readPositiveInteger(intent, 'max_output_bytes') ?? readPositiveInteger(contract.defaults, 'max_output_bytes') ?? 1_048_576,
87
+ successExitCodes: getSuccessExitCodes(intent),
88
+ commandArgv,
89
+ shellCommand,
90
+ mode: getRunPlanMode(commandArgv, intent),
91
+ writes: readStringArray(intent, 'writes'),
92
+ effects: readArray(intent, 'effects'),
93
+ network: readBoolean(intent, 'network'),
94
+ destructive: readBoolean(intent, 'destructive'),
95
+ envPolicy: env.policy,
96
+ envAllowlist: env.allowlist,
97
+ testTargets: [],
98
+ };
99
+ }
100
+ function createBlockedRunPlan(contract, intentName, intent, eligibility, reasonCode, detail) {
101
+ const metadata = intent ? readRunIntentMetadata(contract, intent) : null;
102
+ return {
103
+ intentName,
104
+ intent,
105
+ ok: false,
106
+ eligibility,
107
+ reasonCode,
108
+ detail,
109
+ intentStatus: metadata?.intentStatus ?? null,
110
+ lifecycle: metadata?.lifecycle ?? null,
111
+ runPolicy: metadata?.runPolicy ?? null,
112
+ kind: metadata?.kind ?? null,
113
+ configuredCwd: metadata?.configuredCwd ?? null,
114
+ cwd: null,
115
+ relativeCwd: null,
116
+ timeoutSeconds: metadata?.timeoutSeconds ?? null,
117
+ maxOutputBytes: metadata?.maxOutputBytes ?? null,
118
+ successExitCodes: metadata?.successExitCodes ?? null,
119
+ commandArgv: metadata?.commandArgv,
120
+ shellCommand: metadata?.shellCommand,
121
+ mode: metadata?.mode ?? null,
122
+ argvCommand: undefined,
123
+ writes: metadata?.writes,
124
+ effects: metadata?.effects,
125
+ network: metadata?.network,
126
+ destructive: metadata?.destructive,
127
+ envPolicy: metadata?.envPolicy ?? null,
128
+ envAllowlist: metadata?.envAllowlist ?? [],
129
+ testTargets: [],
130
+ };
131
+ }
132
+ export function createRunPlan(projectRoot, contract, intentName, options = {}) {
133
+ const rawIntent = contract.intents[intentName];
134
+ const eligibility = evaluateCommandIntentEligibility(intentName, rawIntent);
135
+ if (!isRecord(rawIntent)) {
136
+ return createBlockedRunPlan(contract, intentName, undefined, eligibility, 'intent_not_table', eligibility.detail);
137
+ }
138
+ if (!eligibility.ok) {
139
+ return createBlockedRunPlan(contract, intentName, rawIntent, eligibility, eligibility.code, eligibility.detail);
140
+ }
141
+ const metadata = readRunIntentMetadata(contract, rawIntent);
142
+ let cwd;
143
+ try {
144
+ cwd = resolveSafeProjectCwd(projectRoot, metadata.configuredCwd);
145
+ }
146
+ catch (error) {
147
+ return createBlockedRunPlan(contract, intentName, rawIntent, eligibility, 'cwd_outside_project', error instanceof Error ? error.message : String(error));
148
+ }
149
+ const testTargets = commandAcceptsTestTargets(rawIntent) ? normalizeTestTargets(options.testTargets) : [];
150
+ const commandArgv = metadata.commandArgv && testTargets.length > 0 ? [...metadata.commandArgv, ...testTargets] : metadata.commandArgv;
151
+ if (!metadata.timeoutSeconds || !metadata.mode) {
152
+ return createBlockedRunPlan(contract, intentName, rawIntent, eligibility, !metadata.timeoutSeconds ? 'missing_timeout' : 'missing_command_source', !metadata.timeoutSeconds ? 'Intent timeout_seconds is missing or invalid.' : 'Intent does not define argv or shell cmd.');
153
+ }
154
+ return {
155
+ intentName,
156
+ intent: rawIntent,
157
+ ok: true,
158
+ eligibility,
159
+ reasonCode: null,
160
+ detail: null,
161
+ intentStatus: metadata.intentStatus,
162
+ lifecycle: metadata.lifecycle,
163
+ runPolicy: metadata.runPolicy,
164
+ kind: metadata.kind,
165
+ configuredCwd: metadata.configuredCwd,
166
+ cwd,
167
+ relativeCwd: getRelativeProjectPath(projectRoot, cwd),
168
+ timeoutSeconds: metadata.timeoutSeconds,
169
+ maxOutputBytes: metadata.maxOutputBytes,
170
+ successExitCodes: metadata.successExitCodes,
171
+ commandArgv,
172
+ shellCommand: metadata.shellCommand,
173
+ mode: metadata.mode,
174
+ argvCommand: commandArgv ? resolveArgvCommand(rawIntent, commandArgv) : undefined,
175
+ writes: metadata.writes,
176
+ effects: metadata.effects,
177
+ network: metadata.network,
178
+ destructive: metadata.destructive,
179
+ envPolicy: metadata.envPolicy,
180
+ envAllowlist: metadata.envAllowlist,
181
+ testTargets,
182
+ };
183
+ }
184
+ export function createRunPreview(plan, previewMode) {
185
+ return {
186
+ schema_version: '1',
187
+ command: 'run',
188
+ preview: true,
189
+ preview_mode: previewMode,
190
+ intent: plan.intentName,
191
+ runnable: plan.ok,
192
+ eligibility: plan.eligibility,
193
+ reason_code: plan.reasonCode,
194
+ detail: plan.detail,
195
+ status: plan.intentStatus,
196
+ lifecycle: plan.lifecycle,
197
+ run_policy: plan.runPolicy,
198
+ kind: plan.kind,
199
+ configured_cwd: plan.configuredCwd,
200
+ cwd: plan.relativeCwd,
201
+ resolved_cwd: plan.cwd,
202
+ timeout_seconds: plan.timeoutSeconds,
203
+ max_output_bytes: plan.maxOutputBytes,
204
+ mode: plan.mode,
205
+ argv: plan.commandArgv,
206
+ resolved_argv: plan.argvCommand,
207
+ cmd: plan.shellCommand,
208
+ writes: plan.writes,
209
+ effects: plan.effects,
210
+ network: plan.network,
211
+ destructive: plan.destructive,
212
+ env_policy: plan.envPolicy,
213
+ env_allowlist: plan.envAllowlist,
214
+ test_targets: plan.testTargets,
215
+ success_exit_codes: plan.successExitCodes,
216
+ };
217
+ }
218
+ export function renderRunPreviewText(plan, previewMode) {
219
+ const lines = [
220
+ `mf run ${previewMode}`,
221
+ `Intent: ${plan.intentName}`,
222
+ `Runnable: ${plan.ok ? 'yes' : 'no'}`,
223
+ ];
224
+ if (!plan.ok) {
225
+ lines.push(`Reason: ${plan.reasonCode}${plan.detail ? ` (${plan.detail})` : ''}`);
226
+ return lines.join('\n');
227
+ }
228
+ lines.push(`Mode: ${plan.mode}`);
229
+ lines.push(`Cwd: ${plan.relativeCwd}`);
230
+ lines.push(`Timeout: ${plan.timeoutSeconds}s`);
231
+ lines.push(`Environment: ${plan.envPolicy}${plan.envAllowlist.length > 0 ? ` (${plan.envAllowlist.join(', ')})` : ''}`);
232
+ if (plan.commandArgv) {
233
+ lines.push(`Argv: ${plan.commandArgv.join(' ')}`);
234
+ }
235
+ else if (plan.shellCommand) {
236
+ lines.push(`Shell: ${plan.shellCommand}`);
237
+ }
238
+ return lines.join('\n');
239
+ }
@@ -163,17 +163,32 @@ export function getDefaultTemplate() {
163
163
  export function getTemplateFiles(template, locale = template.manifest.defaultLocale, profile = template.manifest.defaultProfile, options = {}) {
164
164
  const commonRoot = path.join(template.templateRoot, template.manifest.commonRoot);
165
165
  const localeRoot = template.manifest.localesRoot ? path.join(template.templateRoot, template.manifest.localesRoot, locale) : undefined;
166
+ const sourceLocaleRoot = template.manifest.localesRoot && locale !== template.manifest.defaultLocale
167
+ ? path.join(template.templateRoot, template.manifest.localesRoot, template.manifest.defaultLocale)
168
+ : undefined;
166
169
  const selectedSkills = selectedSkillNames(template.manifest, profile, options);
167
170
  return template.manifest.creates.filter((relativePath) => shouldIncludeTemplatePath(relativePath, selectedSkills)).map((relativePath) => {
168
171
  const localePath = localeRoot ? path.join(localeRoot, ...relativePath.split('/')) : undefined;
172
+ const sourceLocalePath = sourceLocaleRoot ? path.join(sourceLocaleRoot, ...relativePath.split('/')) : undefined;
169
173
  const commonPath = path.join(commonRoot, ...relativePath.split('/'));
174
+ const localizedPath = localePath && existsSync(localePath) ? localePath : undefined;
175
+ const fallbackLocalePath = sourceLocalePath && existsSync(sourceLocalePath) ? sourceLocalePath : undefined;
176
+ const indexSourcePath = localizedPath ?? fallbackLocalePath ?? commonPath;
170
177
  const content = relativePath === '.mustflow/skills/INDEX.md'
171
- ? filterSkillIndexContent(readFileSync(localePath && existsSync(localePath) ? localePath : commonPath, 'utf8'), selectedSkills)
178
+ ? filterSkillIndexContent(readFileSync(indexSourcePath, 'utf8'), selectedSkills)
172
179
  : undefined;
173
- if (localePath && existsSync(localePath)) {
180
+ if (localizedPath) {
174
181
  return {
175
182
  relativePath,
176
- sourcePath: localePath,
183
+ sourcePath: localizedPath,
184
+ sourceKind: 'locale',
185
+ content,
186
+ };
187
+ }
188
+ if (fallbackLocalePath) {
189
+ return {
190
+ relativePath,
191
+ sourcePath: fallbackLocalePath,
177
192
  sourceKind: 'locale',
178
193
  content,
179
194
  };
@@ -0,0 +1,163 @@
1
+ import { existsSync, readFileSync } from 'node:fs';
2
+ import path from 'node:path';
3
+ import { ensureFileTargetInsideWithoutSymlinks, readUtf8FileInsideWithoutSymlinks } from './filesystem.js';
4
+ const DIFF_PREVIEW_MAX_LINES = 120;
5
+ const DIFF_PREVIEW_MAX_LINE_BYTES = 240;
6
+ const DIFF_PREVIEW_CONTEXT_LINES = 3;
7
+ const DIFF_PREVIEW_TRUNCATION_MARKER = '[... diff preview truncated ...]';
8
+ const DIFF_PREVIEW_LINE_TRUNCATION_MARKER = ' [... line truncated]';
9
+ export function shouldPreviewUpdateDiff(action) {
10
+ return action === 'create' || action === 'update' || action === 'blocked-local-change' || action === 'manual-review';
11
+ }
12
+ function templateFileContent(source) {
13
+ return source.content === undefined ? readFileSync(source.sourcePath, 'utf8') : source.content;
14
+ }
15
+ function shouldOmitDiffPreview(relativePath) {
16
+ const normalizedPath = relativePath.replaceAll('\\', '/');
17
+ const lowerPath = normalizedPath.toLowerCase();
18
+ return (normalizedPath.startsWith('.mustflow/state/') ||
19
+ normalizedPath.startsWith('.mustflow/cache/') ||
20
+ normalizedPath.startsWith('.mustflow/backups/') ||
21
+ lowerPath === '.env' ||
22
+ lowerPath.startsWith('.env.') ||
23
+ lowerPath.endsWith('.pem') ||
24
+ lowerPath.endsWith('.key'));
25
+ }
26
+ function unavailableDiffPreview(reason) {
27
+ return {
28
+ format: 'unified',
29
+ available: false,
30
+ from: 'unavailable',
31
+ to: 'bundled_template',
32
+ bounded: true,
33
+ truncated: false,
34
+ max_lines: DIFF_PREVIEW_MAX_LINES,
35
+ max_line_bytes: DIFF_PREVIEW_MAX_LINE_BYTES,
36
+ lines: [],
37
+ reason,
38
+ };
39
+ }
40
+ function splitDiffLines(content) {
41
+ const normalized = content.replace(/\r\n/g, '\n').replace(/\r/g, '\n');
42
+ if (normalized.length === 0) {
43
+ return [];
44
+ }
45
+ return normalized.endsWith('\n') ? normalized.slice(0, -1).split('\n') : normalized.split('\n');
46
+ }
47
+ function unifiedRange(startIndex, count) {
48
+ if (count === 0) {
49
+ return `${startIndex},0`;
50
+ }
51
+ return `${startIndex + 1},${count}`;
52
+ }
53
+ function truncateDiffLine(line) {
54
+ if (Buffer.byteLength(line, 'utf8') <= DIFF_PREVIEW_MAX_LINE_BYTES) {
55
+ return { line, truncated: false };
56
+ }
57
+ let result = '';
58
+ for (const character of line) {
59
+ const candidate = `${result}${character}${DIFF_PREVIEW_LINE_TRUNCATION_MARKER}`;
60
+ if (Buffer.byteLength(candidate, 'utf8') > DIFF_PREVIEW_MAX_LINE_BYTES) {
61
+ break;
62
+ }
63
+ result += character;
64
+ }
65
+ return {
66
+ line: `${result}${DIFF_PREVIEW_LINE_TRUNCATION_MARKER}`,
67
+ truncated: true,
68
+ };
69
+ }
70
+ function boundDiffLines(lines) {
71
+ const bounded = [];
72
+ let truncated = false;
73
+ for (const line of lines) {
74
+ if (bounded.length >= DIFF_PREVIEW_MAX_LINES) {
75
+ truncated = true;
76
+ break;
77
+ }
78
+ const boundedLine = truncateDiffLine(line);
79
+ truncated = truncated || boundedLine.truncated;
80
+ bounded.push(boundedLine.line);
81
+ }
82
+ if (truncated) {
83
+ if (bounded.length >= DIFF_PREVIEW_MAX_LINES) {
84
+ bounded[bounded.length - 1] = DIFF_PREVIEW_TRUNCATION_MARKER;
85
+ }
86
+ else {
87
+ bounded.push(DIFF_PREVIEW_TRUNCATION_MARKER);
88
+ }
89
+ }
90
+ return { lines: bounded, truncated };
91
+ }
92
+ function createUnifiedDiffLines(relativePath, currentContent, templateContent, targetExists) {
93
+ const currentLines = splitDiffLines(currentContent);
94
+ const templateLines = splitDiffLines(templateContent);
95
+ let prefixLength = 0;
96
+ while (prefixLength < currentLines.length &&
97
+ prefixLength < templateLines.length &&
98
+ currentLines[prefixLength] === templateLines[prefixLength]) {
99
+ prefixLength += 1;
100
+ }
101
+ let suffixLength = 0;
102
+ while (suffixLength < currentLines.length - prefixLength &&
103
+ suffixLength < templateLines.length - prefixLength &&
104
+ currentLines[currentLines.length - 1 - suffixLength] === templateLines[templateLines.length - 1 - suffixLength]) {
105
+ suffixLength += 1;
106
+ }
107
+ const currentChangeEnd = currentLines.length - suffixLength;
108
+ const templateChangeEnd = templateLines.length - suffixLength;
109
+ const currentStart = Math.max(0, prefixLength - DIFF_PREVIEW_CONTEXT_LINES);
110
+ const templateStart = Math.max(0, prefixLength - DIFF_PREVIEW_CONTEXT_LINES);
111
+ const currentEnd = Math.min(currentLines.length, currentChangeEnd + DIFF_PREVIEW_CONTEXT_LINES);
112
+ const templateEnd = Math.min(templateLines.length, templateChangeEnd + DIFF_PREVIEW_CONTEXT_LINES);
113
+ const lines = [
114
+ targetExists ? `--- ${relativePath} (current)` : '--- /dev/null',
115
+ `+++ ${relativePath} (template)`,
116
+ `@@ -${unifiedRange(currentStart, currentEnd - currentStart)} +${unifiedRange(templateStart, templateEnd - templateStart)} @@`,
117
+ ];
118
+ for (let index = currentStart; index < prefixLength; index += 1) {
119
+ lines.push(` ${currentLines[index]}`);
120
+ }
121
+ for (let index = prefixLength; index < currentChangeEnd; index += 1) {
122
+ lines.push(`-${currentLines[index]}`);
123
+ }
124
+ for (let index = prefixLength; index < templateChangeEnd; index += 1) {
125
+ lines.push(`+${templateLines[index]}`);
126
+ }
127
+ for (let index = currentChangeEnd; index < currentEnd; index += 1) {
128
+ lines.push(` ${currentLines[index]}`);
129
+ }
130
+ return lines;
131
+ }
132
+ export function createUpdateDiffPreview(projectRoot, input) {
133
+ if (shouldOmitDiffPreview(input.relativePath)) {
134
+ return unavailableDiffPreview('diff preview omitted for generated state, cache, backup, or sensitive-looking path');
135
+ }
136
+ const targetPath = path.join(projectRoot, input.relativePath);
137
+ const targetExists = existsSync(targetPath);
138
+ try {
139
+ if (targetExists) {
140
+ ensureFileTargetInsideWithoutSymlinks(projectRoot, targetPath);
141
+ }
142
+ else {
143
+ ensureFileTargetInsideWithoutSymlinks(projectRoot, targetPath, { allowMissingLeaf: true });
144
+ }
145
+ const currentContent = targetExists ? readUtf8FileInsideWithoutSymlinks(projectRoot, targetPath) : '';
146
+ const templateContent = templateFileContent(input.source);
147
+ const boundedLines = boundDiffLines(createUnifiedDiffLines(input.relativePath, currentContent, templateContent, targetExists));
148
+ return {
149
+ format: 'unified',
150
+ available: true,
151
+ from: targetExists ? 'current_target' : 'missing_target',
152
+ to: 'bundled_template',
153
+ bounded: true,
154
+ truncated: boundedLines.truncated,
155
+ max_lines: DIFF_PREVIEW_MAX_LINES,
156
+ max_line_bytes: DIFF_PREVIEW_MAX_LINE_BYTES,
157
+ lines: boundedLines.lines,
158
+ };
159
+ }
160
+ catch (error) {
161
+ return unavailableDiffPreview(error instanceof Error ? error.message : String(error));
162
+ }
163
+ }