mustflow 1.15.97

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 (415) hide show
  1. package/LICENSE +16 -0
  2. package/README.md +422 -0
  3. package/dist/cli/commands/check.js +73 -0
  4. package/dist/cli/commands/classify.js +104 -0
  5. package/dist/cli/commands/context.js +95 -0
  6. package/dist/cli/commands/contract-lint.js +74 -0
  7. package/dist/cli/commands/dashboard.js +654 -0
  8. package/dist/cli/commands/docs.js +382 -0
  9. package/dist/cli/commands/doctor.js +232 -0
  10. package/dist/cli/commands/explain.js +293 -0
  11. package/dist/cli/commands/help.js +148 -0
  12. package/dist/cli/commands/impact.js +120 -0
  13. package/dist/cli/commands/index.js +70 -0
  14. package/dist/cli/commands/init.js +986 -0
  15. package/dist/cli/commands/line-endings.js +102 -0
  16. package/dist/cli/commands/map.js +95 -0
  17. package/dist/cli/commands/run.js +442 -0
  18. package/dist/cli/commands/search.js +166 -0
  19. package/dist/cli/commands/status.js +65 -0
  20. package/dist/cli/commands/update.js +443 -0
  21. package/dist/cli/commands/verify.js +448 -0
  22. package/dist/cli/commands/version-sources.js +79 -0
  23. package/dist/cli/commands/version.js +57 -0
  24. package/dist/cli/i18n/en.js +702 -0
  25. package/dist/cli/i18n/es.js +702 -0
  26. package/dist/cli/i18n/fr.js +702 -0
  27. package/dist/cli/i18n/hi.js +702 -0
  28. package/dist/cli/i18n/ko.js +702 -0
  29. package/dist/cli/i18n/zh.js +702 -0
  30. package/dist/cli/index.js +218 -0
  31. package/dist/cli/lib/agent-context.js +342 -0
  32. package/dist/cli/lib/browser-open.js +58 -0
  33. package/dist/cli/lib/cli-output.js +36 -0
  34. package/dist/cli/lib/command-contract.js +1 -0
  35. package/dist/cli/lib/command-registry.js +107 -0
  36. package/dist/cli/lib/dashboard-html.js +1866 -0
  37. package/dist/cli/lib/dashboard-locale.js +309 -0
  38. package/dist/cli/lib/dashboard-preferences.js +405 -0
  39. package/dist/cli/lib/doc-review-ledger.js +226 -0
  40. package/dist/cli/lib/filesystem.js +125 -0
  41. package/dist/cli/lib/git-changes.js +13 -0
  42. package/dist/cli/lib/i18n.js +55 -0
  43. package/dist/cli/lib/local-index.js +1014 -0
  44. package/dist/cli/lib/locale-tags.js +4 -0
  45. package/dist/cli/lib/manifest-lock.js +131 -0
  46. package/dist/cli/lib/npm-version-check.js +97 -0
  47. package/dist/cli/lib/package-info.js +13 -0
  48. package/dist/cli/lib/preferences-options.js +8 -0
  49. package/dist/cli/lib/project-root.js +23 -0
  50. package/dist/cli/lib/repo-map.js +635 -0
  51. package/dist/cli/lib/reporter.js +8 -0
  52. package/dist/cli/lib/run-receipt.js +1 -0
  53. package/dist/cli/lib/template-i18n.js +265 -0
  54. package/dist/cli/lib/templates.js +188 -0
  55. package/dist/cli/lib/toml.js +1 -0
  56. package/dist/cli/lib/validation.js +1639 -0
  57. package/dist/cli/lib/version-sources.js +1 -0
  58. package/dist/core/authority-resolution.js +155 -0
  59. package/dist/core/change-classification.js +122 -0
  60. package/dist/core/change-verification.js +80 -0
  61. package/dist/core/check-issues.js +67 -0
  62. package/dist/core/command-classification.js +22 -0
  63. package/dist/core/command-contract-rules.js +27 -0
  64. package/dist/core/command-contract-validation.js +197 -0
  65. package/dist/core/command-cwd.js +12 -0
  66. package/dist/core/command-effects.js +182 -0
  67. package/dist/core/command-explanation.js +135 -0
  68. package/dist/core/command-intent-eligibility.js +76 -0
  69. package/dist/core/config-loading.js +54 -0
  70. package/dist/core/contract-lint.js +110 -0
  71. package/dist/core/contract-models.js +53 -0
  72. package/dist/core/dashboard-verification.js +132 -0
  73. package/dist/core/doc-review-triage.js +92 -0
  74. package/dist/core/line-endings.js +144 -0
  75. package/dist/core/public-json-contracts.js +112 -0
  76. package/dist/core/public-surface-explanation.js +49 -0
  77. package/dist/core/release-version-validation.js +53 -0
  78. package/dist/core/retention-explanation.js +74 -0
  79. package/dist/core/retention-policy.js +57 -0
  80. package/dist/core/run-receipt.js +77 -0
  81. package/dist/core/skill-route-alignment.js +100 -0
  82. package/dist/core/skill-route-explanation.js +117 -0
  83. package/dist/core/source-anchor-explanation.js +33 -0
  84. package/dist/core/source-anchor-status.js +269 -0
  85. package/dist/core/source-anchor-symbols.js +181 -0
  86. package/dist/core/source-anchor-validation.js +158 -0
  87. package/dist/core/source-anchors.js +194 -0
  88. package/dist/core/surface-decision-model.js +18 -0
  89. package/dist/core/toml.js +11 -0
  90. package/dist/core/verification-plan.js +41 -0
  91. package/dist/core/verification-scheduler.js +92 -0
  92. package/dist/core/version-impact.js +54 -0
  93. package/dist/core/version-sources.js +235 -0
  94. package/dist/core/version-sync-policy.js +85 -0
  95. package/examples/README.md +13 -0
  96. package/examples/docs-only/README.md +72 -0
  97. package/examples/host-instruction-conflicts/README.md +47 -0
  98. package/examples/minimal-js/README.md +98 -0
  99. package/examples/missing-command-contracts/README.md +70 -0
  100. package/examples/nested-repos/README.md +62 -0
  101. package/package.json +80 -0
  102. package/schemas/README.md +32 -0
  103. package/schemas/change-verification-report.schema.json +319 -0
  104. package/schemas/classify-report.schema.json +113 -0
  105. package/schemas/commands.schema.json +116 -0
  106. package/schemas/context-report.schema.json +341 -0
  107. package/schemas/contract-lint-report.schema.json +61 -0
  108. package/schemas/docs-review-list.schema.json +72 -0
  109. package/schemas/doctor-report.schema.json +175 -0
  110. package/schemas/explain-report.schema.json +471 -0
  111. package/schemas/impact-report.schema.json +121 -0
  112. package/schemas/line-endings-report.schema.json +63 -0
  113. package/schemas/run-receipt.schema.json +75 -0
  114. package/schemas/verify-report.schema.json +67 -0
  115. package/schemas/version-sources-report.schema.json +42 -0
  116. package/templates/default/common/.mustflow/config/commands.toml +251 -0
  117. package/templates/default/common/.mustflow/config/mustflow.toml +424 -0
  118. package/templates/default/common/.mustflow/config/preferences.toml +125 -0
  119. package/templates/default/common/gitignore.mustflow +9 -0
  120. package/templates/default/i18n.toml +483 -0
  121. package/templates/default/locales/en/.mustflow/context/INDEX.md +39 -0
  122. package/templates/default/locales/en/.mustflow/context/PROJECT.md +66 -0
  123. package/templates/default/locales/en/.mustflow/docs/agent-workflow.md +345 -0
  124. package/templates/default/locales/en/.mustflow/skills/INDEX.md +78 -0
  125. package/templates/default/locales/en/.mustflow/skills/adapter-boundary/SKILL.md +193 -0
  126. package/templates/default/locales/en/.mustflow/skills/artifact-integrity-check/SKILL.md +121 -0
  127. package/templates/default/locales/en/.mustflow/skills/behavior-preserving-refactor/SKILL.md +182 -0
  128. package/templates/default/locales/en/.mustflow/skills/code-review/SKILL.md +115 -0
  129. package/templates/default/locales/en/.mustflow/skills/codebase-orientation/SKILL.md +115 -0
  130. package/templates/default/locales/en/.mustflow/skills/command-pattern/SKILL.md +247 -0
  131. package/templates/default/locales/en/.mustflow/skills/composition-over-inheritance/SKILL.md +176 -0
  132. package/templates/default/locales/en/.mustflow/skills/contract-sync-check/SKILL.md +116 -0
  133. package/templates/default/locales/en/.mustflow/skills/date-number-audit/SKILL.md +116 -0
  134. package/templates/default/locales/en/.mustflow/skills/dependency-injection/SKILL.md +161 -0
  135. package/templates/default/locales/en/.mustflow/skills/dependency-reality-check/SKILL.md +115 -0
  136. package/templates/default/locales/en/.mustflow/skills/diff-risk-review/SKILL.md +143 -0
  137. package/templates/default/locales/en/.mustflow/skills/docs-prose-review/SKILL.md +119 -0
  138. package/templates/default/locales/en/.mustflow/skills/docs-update/SKILL.md +100 -0
  139. package/templates/default/locales/en/.mustflow/skills/external-prompt-injection-defense/SKILL.md +124 -0
  140. package/templates/default/locales/en/.mustflow/skills/facade-pattern/SKILL.md +210 -0
  141. package/templates/default/locales/en/.mustflow/skills/failure-triage/SKILL.md +97 -0
  142. package/templates/default/locales/en/.mustflow/skills/instruction-conflict-scope-check/SKILL.md +118 -0
  143. package/templates/default/locales/en/.mustflow/skills/line-ending-hygiene/SKILL.md +111 -0
  144. package/templates/default/locales/en/.mustflow/skills/migration-safety-check/SKILL.md +117 -0
  145. package/templates/default/locales/en/.mustflow/skills/multi-agent-work-coordination/SKILL.md +260 -0
  146. package/templates/default/locales/en/.mustflow/skills/null-object-pattern/SKILL.md +196 -0
  147. package/templates/default/locales/en/.mustflow/skills/pattern-scout/SKILL.md +110 -0
  148. package/templates/default/locales/en/.mustflow/skills/performance-budget-check/SKILL.md +121 -0
  149. package/templates/default/locales/en/.mustflow/skills/project-context-authoring/SKILL.md +107 -0
  150. package/templates/default/locales/en/.mustflow/skills/pure-core-imperative-shell/SKILL.md +212 -0
  151. package/templates/default/locales/en/.mustflow/skills/readme-authoring/SKILL.md +115 -0
  152. package/templates/default/locales/en/.mustflow/skills/repo-improvement-loop/SKILL.md +150 -0
  153. package/templates/default/locales/en/.mustflow/skills/repro-first-debug/SKILL.md +112 -0
  154. package/templates/default/locales/en/.mustflow/skills/requirement-regression-guard/SKILL.md +152 -0
  155. package/templates/default/locales/en/.mustflow/skills/result-option/SKILL.md +186 -0
  156. package/templates/default/locales/en/.mustflow/skills/security-privacy-review/SKILL.md +130 -0
  157. package/templates/default/locales/en/.mustflow/skills/security-regression-tests/SKILL.md +157 -0
  158. package/templates/default/locales/en/.mustflow/skills/skill-authoring/SKILL.md +110 -0
  159. package/templates/default/locales/en/.mustflow/skills/source-freshness-check/SKILL.md +111 -0
  160. package/templates/default/locales/en/.mustflow/skills/state-machine-pattern/SKILL.md +214 -0
  161. package/templates/default/locales/en/.mustflow/skills/strategy-pattern/SKILL.md +215 -0
  162. package/templates/default/locales/en/.mustflow/skills/structure-discovery-gate/SKILL.md +159 -0
  163. package/templates/default/locales/en/.mustflow/skills/test-maintenance/SKILL.md +122 -0
  164. package/templates/default/locales/en/.mustflow/skills/ui-quality-gate/SKILL.md +119 -0
  165. package/templates/default/locales/en/.mustflow/skills/visual-review-artifact/SKILL.md +127 -0
  166. package/templates/default/locales/en/.mustflow/skills/visual-review-artifact/assets/review-template.html +286 -0
  167. package/templates/default/locales/en/.mustflow/skills/visual-review-artifact/resources.toml +7 -0
  168. package/templates/default/locales/en/.mustflow/skills/web-asset-optimization/SKILL.md +108 -0
  169. package/templates/default/locales/en/AGENTS.md +114 -0
  170. package/templates/default/locales/es/.mustflow/context/INDEX.md +39 -0
  171. package/templates/default/locales/es/.mustflow/context/PROJECT.md +63 -0
  172. package/templates/default/locales/es/.mustflow/docs/agent-workflow.md +365 -0
  173. package/templates/default/locales/es/.mustflow/skills/INDEX.md +78 -0
  174. package/templates/default/locales/es/.mustflow/skills/adapter-boundary/SKILL.md +193 -0
  175. package/templates/default/locales/es/.mustflow/skills/artifact-integrity-check/SKILL.md +114 -0
  176. package/templates/default/locales/es/.mustflow/skills/behavior-preserving-refactor/SKILL.md +182 -0
  177. package/templates/default/locales/es/.mustflow/skills/code-review/SKILL.md +115 -0
  178. package/templates/default/locales/es/.mustflow/skills/codebase-orientation/SKILL.md +115 -0
  179. package/templates/default/locales/es/.mustflow/skills/command-pattern/SKILL.md +247 -0
  180. package/templates/default/locales/es/.mustflow/skills/composition-over-inheritance/SKILL.md +176 -0
  181. package/templates/default/locales/es/.mustflow/skills/contract-sync-check/SKILL.md +116 -0
  182. package/templates/default/locales/es/.mustflow/skills/date-number-audit/SKILL.md +116 -0
  183. package/templates/default/locales/es/.mustflow/skills/dependency-injection/SKILL.md +161 -0
  184. package/templates/default/locales/es/.mustflow/skills/dependency-reality-check/SKILL.md +115 -0
  185. package/templates/default/locales/es/.mustflow/skills/diff-risk-review/SKILL.md +136 -0
  186. package/templates/default/locales/es/.mustflow/skills/docs-prose-review/SKILL.md +119 -0
  187. package/templates/default/locales/es/.mustflow/skills/docs-update/SKILL.md +97 -0
  188. package/templates/default/locales/es/.mustflow/skills/external-prompt-injection-defense/SKILL.md +116 -0
  189. package/templates/default/locales/es/.mustflow/skills/facade-pattern/SKILL.md +210 -0
  190. package/templates/default/locales/es/.mustflow/skills/failure-triage/SKILL.md +97 -0
  191. package/templates/default/locales/es/.mustflow/skills/instruction-conflict-scope-check/SKILL.md +118 -0
  192. package/templates/default/locales/es/.mustflow/skills/line-ending-hygiene/SKILL.md +111 -0
  193. package/templates/default/locales/es/.mustflow/skills/migration-safety-check/SKILL.md +117 -0
  194. package/templates/default/locales/es/.mustflow/skills/multi-agent-work-coordination/SKILL.md +260 -0
  195. package/templates/default/locales/es/.mustflow/skills/null-object-pattern/SKILL.md +196 -0
  196. package/templates/default/locales/es/.mustflow/skills/pattern-scout/SKILL.md +110 -0
  197. package/templates/default/locales/es/.mustflow/skills/performance-budget-check/SKILL.md +121 -0
  198. package/templates/default/locales/es/.mustflow/skills/project-context-authoring/SKILL.md +107 -0
  199. package/templates/default/locales/es/.mustflow/skills/pure-core-imperative-shell/SKILL.md +212 -0
  200. package/templates/default/locales/es/.mustflow/skills/readme-authoring/SKILL.md +115 -0
  201. package/templates/default/locales/es/.mustflow/skills/repo-improvement-loop/SKILL.md +150 -0
  202. package/templates/default/locales/es/.mustflow/skills/repro-first-debug/SKILL.md +112 -0
  203. package/templates/default/locales/es/.mustflow/skills/requirement-regression-guard/SKILL.md +152 -0
  204. package/templates/default/locales/es/.mustflow/skills/result-option/SKILL.md +186 -0
  205. package/templates/default/locales/es/.mustflow/skills/security-privacy-review/SKILL.md +116 -0
  206. package/templates/default/locales/es/.mustflow/skills/security-regression-tests/SKILL.md +131 -0
  207. package/templates/default/locales/es/.mustflow/skills/skill-authoring/SKILL.md +110 -0
  208. package/templates/default/locales/es/.mustflow/skills/source-freshness-check/SKILL.md +111 -0
  209. package/templates/default/locales/es/.mustflow/skills/state-machine-pattern/SKILL.md +214 -0
  210. package/templates/default/locales/es/.mustflow/skills/strategy-pattern/SKILL.md +215 -0
  211. package/templates/default/locales/es/.mustflow/skills/structure-discovery-gate/SKILL.md +159 -0
  212. package/templates/default/locales/es/.mustflow/skills/test-maintenance/SKILL.md +122 -0
  213. package/templates/default/locales/es/.mustflow/skills/ui-quality-gate/SKILL.md +117 -0
  214. package/templates/default/locales/es/.mustflow/skills/visual-review-artifact/SKILL.md +127 -0
  215. package/templates/default/locales/es/.mustflow/skills/visual-review-artifact/assets/review-template.html +286 -0
  216. package/templates/default/locales/es/.mustflow/skills/visual-review-artifact/resources.toml +7 -0
  217. package/templates/default/locales/es/.mustflow/skills/web-asset-optimization/SKILL.md +108 -0
  218. package/templates/default/locales/es/AGENTS.md +83 -0
  219. package/templates/default/locales/fr/.mustflow/context/INDEX.md +39 -0
  220. package/templates/default/locales/fr/.mustflow/context/PROJECT.md +63 -0
  221. package/templates/default/locales/fr/.mustflow/docs/agent-workflow.md +368 -0
  222. package/templates/default/locales/fr/.mustflow/skills/INDEX.md +78 -0
  223. package/templates/default/locales/fr/.mustflow/skills/adapter-boundary/SKILL.md +193 -0
  224. package/templates/default/locales/fr/.mustflow/skills/artifact-integrity-check/SKILL.md +114 -0
  225. package/templates/default/locales/fr/.mustflow/skills/behavior-preserving-refactor/SKILL.md +182 -0
  226. package/templates/default/locales/fr/.mustflow/skills/code-review/SKILL.md +115 -0
  227. package/templates/default/locales/fr/.mustflow/skills/codebase-orientation/SKILL.md +115 -0
  228. package/templates/default/locales/fr/.mustflow/skills/command-pattern/SKILL.md +247 -0
  229. package/templates/default/locales/fr/.mustflow/skills/composition-over-inheritance/SKILL.md +176 -0
  230. package/templates/default/locales/fr/.mustflow/skills/contract-sync-check/SKILL.md +116 -0
  231. package/templates/default/locales/fr/.mustflow/skills/date-number-audit/SKILL.md +116 -0
  232. package/templates/default/locales/fr/.mustflow/skills/dependency-injection/SKILL.md +161 -0
  233. package/templates/default/locales/fr/.mustflow/skills/dependency-reality-check/SKILL.md +115 -0
  234. package/templates/default/locales/fr/.mustflow/skills/diff-risk-review/SKILL.md +136 -0
  235. package/templates/default/locales/fr/.mustflow/skills/docs-prose-review/SKILL.md +119 -0
  236. package/templates/default/locales/fr/.mustflow/skills/docs-update/SKILL.md +97 -0
  237. package/templates/default/locales/fr/.mustflow/skills/external-prompt-injection-defense/SKILL.md +116 -0
  238. package/templates/default/locales/fr/.mustflow/skills/facade-pattern/SKILL.md +210 -0
  239. package/templates/default/locales/fr/.mustflow/skills/failure-triage/SKILL.md +97 -0
  240. package/templates/default/locales/fr/.mustflow/skills/instruction-conflict-scope-check/SKILL.md +118 -0
  241. package/templates/default/locales/fr/.mustflow/skills/line-ending-hygiene/SKILL.md +111 -0
  242. package/templates/default/locales/fr/.mustflow/skills/migration-safety-check/SKILL.md +117 -0
  243. package/templates/default/locales/fr/.mustflow/skills/multi-agent-work-coordination/SKILL.md +260 -0
  244. package/templates/default/locales/fr/.mustflow/skills/null-object-pattern/SKILL.md +196 -0
  245. package/templates/default/locales/fr/.mustflow/skills/pattern-scout/SKILL.md +110 -0
  246. package/templates/default/locales/fr/.mustflow/skills/performance-budget-check/SKILL.md +121 -0
  247. package/templates/default/locales/fr/.mustflow/skills/project-context-authoring/SKILL.md +107 -0
  248. package/templates/default/locales/fr/.mustflow/skills/pure-core-imperative-shell/SKILL.md +212 -0
  249. package/templates/default/locales/fr/.mustflow/skills/readme-authoring/SKILL.md +115 -0
  250. package/templates/default/locales/fr/.mustflow/skills/repo-improvement-loop/SKILL.md +150 -0
  251. package/templates/default/locales/fr/.mustflow/skills/repro-first-debug/SKILL.md +112 -0
  252. package/templates/default/locales/fr/.mustflow/skills/requirement-regression-guard/SKILL.md +152 -0
  253. package/templates/default/locales/fr/.mustflow/skills/result-option/SKILL.md +186 -0
  254. package/templates/default/locales/fr/.mustflow/skills/security-privacy-review/SKILL.md +116 -0
  255. package/templates/default/locales/fr/.mustflow/skills/security-regression-tests/SKILL.md +131 -0
  256. package/templates/default/locales/fr/.mustflow/skills/skill-authoring/SKILL.md +110 -0
  257. package/templates/default/locales/fr/.mustflow/skills/source-freshness-check/SKILL.md +111 -0
  258. package/templates/default/locales/fr/.mustflow/skills/state-machine-pattern/SKILL.md +214 -0
  259. package/templates/default/locales/fr/.mustflow/skills/strategy-pattern/SKILL.md +215 -0
  260. package/templates/default/locales/fr/.mustflow/skills/structure-discovery-gate/SKILL.md +159 -0
  261. package/templates/default/locales/fr/.mustflow/skills/test-maintenance/SKILL.md +122 -0
  262. package/templates/default/locales/fr/.mustflow/skills/ui-quality-gate/SKILL.md +117 -0
  263. package/templates/default/locales/fr/.mustflow/skills/visual-review-artifact/SKILL.md +127 -0
  264. package/templates/default/locales/fr/.mustflow/skills/visual-review-artifact/assets/review-template.html +286 -0
  265. package/templates/default/locales/fr/.mustflow/skills/visual-review-artifact/resources.toml +7 -0
  266. package/templates/default/locales/fr/.mustflow/skills/web-asset-optimization/SKILL.md +108 -0
  267. package/templates/default/locales/fr/AGENTS.md +84 -0
  268. package/templates/default/locales/hi/.mustflow/context/INDEX.md +39 -0
  269. package/templates/default/locales/hi/.mustflow/context/PROJECT.md +65 -0
  270. package/templates/default/locales/hi/.mustflow/docs/agent-workflow.md +359 -0
  271. package/templates/default/locales/hi/.mustflow/skills/INDEX.md +78 -0
  272. package/templates/default/locales/hi/.mustflow/skills/adapter-boundary/SKILL.md +193 -0
  273. package/templates/default/locales/hi/.mustflow/skills/artifact-integrity-check/SKILL.md +114 -0
  274. package/templates/default/locales/hi/.mustflow/skills/behavior-preserving-refactor/SKILL.md +182 -0
  275. package/templates/default/locales/hi/.mustflow/skills/code-review/SKILL.md +115 -0
  276. package/templates/default/locales/hi/.mustflow/skills/codebase-orientation/SKILL.md +115 -0
  277. package/templates/default/locales/hi/.mustflow/skills/command-pattern/SKILL.md +247 -0
  278. package/templates/default/locales/hi/.mustflow/skills/composition-over-inheritance/SKILL.md +176 -0
  279. package/templates/default/locales/hi/.mustflow/skills/contract-sync-check/SKILL.md +116 -0
  280. package/templates/default/locales/hi/.mustflow/skills/date-number-audit/SKILL.md +116 -0
  281. package/templates/default/locales/hi/.mustflow/skills/dependency-injection/SKILL.md +161 -0
  282. package/templates/default/locales/hi/.mustflow/skills/dependency-reality-check/SKILL.md +115 -0
  283. package/templates/default/locales/hi/.mustflow/skills/diff-risk-review/SKILL.md +136 -0
  284. package/templates/default/locales/hi/.mustflow/skills/docs-prose-review/SKILL.md +119 -0
  285. package/templates/default/locales/hi/.mustflow/skills/docs-update/SKILL.md +97 -0
  286. package/templates/default/locales/hi/.mustflow/skills/external-prompt-injection-defense/SKILL.md +116 -0
  287. package/templates/default/locales/hi/.mustflow/skills/facade-pattern/SKILL.md +210 -0
  288. package/templates/default/locales/hi/.mustflow/skills/failure-triage/SKILL.md +97 -0
  289. package/templates/default/locales/hi/.mustflow/skills/instruction-conflict-scope-check/SKILL.md +118 -0
  290. package/templates/default/locales/hi/.mustflow/skills/line-ending-hygiene/SKILL.md +111 -0
  291. package/templates/default/locales/hi/.mustflow/skills/migration-safety-check/SKILL.md +117 -0
  292. package/templates/default/locales/hi/.mustflow/skills/multi-agent-work-coordination/SKILL.md +260 -0
  293. package/templates/default/locales/hi/.mustflow/skills/null-object-pattern/SKILL.md +196 -0
  294. package/templates/default/locales/hi/.mustflow/skills/pattern-scout/SKILL.md +110 -0
  295. package/templates/default/locales/hi/.mustflow/skills/performance-budget-check/SKILL.md +121 -0
  296. package/templates/default/locales/hi/.mustflow/skills/project-context-authoring/SKILL.md +107 -0
  297. package/templates/default/locales/hi/.mustflow/skills/pure-core-imperative-shell/SKILL.md +212 -0
  298. package/templates/default/locales/hi/.mustflow/skills/readme-authoring/SKILL.md +115 -0
  299. package/templates/default/locales/hi/.mustflow/skills/repo-improvement-loop/SKILL.md +150 -0
  300. package/templates/default/locales/hi/.mustflow/skills/repro-first-debug/SKILL.md +112 -0
  301. package/templates/default/locales/hi/.mustflow/skills/requirement-regression-guard/SKILL.md +152 -0
  302. package/templates/default/locales/hi/.mustflow/skills/result-option/SKILL.md +186 -0
  303. package/templates/default/locales/hi/.mustflow/skills/security-privacy-review/SKILL.md +116 -0
  304. package/templates/default/locales/hi/.mustflow/skills/security-regression-tests/SKILL.md +131 -0
  305. package/templates/default/locales/hi/.mustflow/skills/skill-authoring/SKILL.md +110 -0
  306. package/templates/default/locales/hi/.mustflow/skills/source-freshness-check/SKILL.md +111 -0
  307. package/templates/default/locales/hi/.mustflow/skills/state-machine-pattern/SKILL.md +214 -0
  308. package/templates/default/locales/hi/.mustflow/skills/strategy-pattern/SKILL.md +215 -0
  309. package/templates/default/locales/hi/.mustflow/skills/structure-discovery-gate/SKILL.md +159 -0
  310. package/templates/default/locales/hi/.mustflow/skills/test-maintenance/SKILL.md +122 -0
  311. package/templates/default/locales/hi/.mustflow/skills/ui-quality-gate/SKILL.md +117 -0
  312. package/templates/default/locales/hi/.mustflow/skills/visual-review-artifact/SKILL.md +127 -0
  313. package/templates/default/locales/hi/.mustflow/skills/visual-review-artifact/assets/review-template.html +286 -0
  314. package/templates/default/locales/hi/.mustflow/skills/visual-review-artifact/resources.toml +7 -0
  315. package/templates/default/locales/hi/.mustflow/skills/web-asset-optimization/SKILL.md +108 -0
  316. package/templates/default/locales/hi/AGENTS.md +83 -0
  317. package/templates/default/locales/ko/.mustflow/context/INDEX.md +39 -0
  318. package/templates/default/locales/ko/.mustflow/context/PROJECT.md +66 -0
  319. package/templates/default/locales/ko/.mustflow/docs/agent-workflow.md +506 -0
  320. package/templates/default/locales/ko/.mustflow/skills/INDEX.md +78 -0
  321. package/templates/default/locales/ko/.mustflow/skills/adapter-boundary/SKILL.md +193 -0
  322. package/templates/default/locales/ko/.mustflow/skills/artifact-integrity-check/SKILL.md +114 -0
  323. package/templates/default/locales/ko/.mustflow/skills/behavior-preserving-refactor/SKILL.md +182 -0
  324. package/templates/default/locales/ko/.mustflow/skills/code-review/SKILL.md +118 -0
  325. package/templates/default/locales/ko/.mustflow/skills/codebase-orientation/SKILL.md +115 -0
  326. package/templates/default/locales/ko/.mustflow/skills/command-pattern/SKILL.md +247 -0
  327. package/templates/default/locales/ko/.mustflow/skills/composition-over-inheritance/SKILL.md +176 -0
  328. package/templates/default/locales/ko/.mustflow/skills/contract-sync-check/SKILL.md +116 -0
  329. package/templates/default/locales/ko/.mustflow/skills/date-number-audit/SKILL.md +116 -0
  330. package/templates/default/locales/ko/.mustflow/skills/dependency-injection/SKILL.md +161 -0
  331. package/templates/default/locales/ko/.mustflow/skills/dependency-reality-check/SKILL.md +115 -0
  332. package/templates/default/locales/ko/.mustflow/skills/diff-risk-review/SKILL.md +136 -0
  333. package/templates/default/locales/ko/.mustflow/skills/docs-prose-review/SKILL.md +119 -0
  334. package/templates/default/locales/ko/.mustflow/skills/docs-update/SKILL.md +107 -0
  335. package/templates/default/locales/ko/.mustflow/skills/external-prompt-injection-defense/SKILL.md +116 -0
  336. package/templates/default/locales/ko/.mustflow/skills/facade-pattern/SKILL.md +210 -0
  337. package/templates/default/locales/ko/.mustflow/skills/failure-triage/SKILL.md +119 -0
  338. package/templates/default/locales/ko/.mustflow/skills/instruction-conflict-scope-check/SKILL.md +118 -0
  339. package/templates/default/locales/ko/.mustflow/skills/line-ending-hygiene/SKILL.md +111 -0
  340. package/templates/default/locales/ko/.mustflow/skills/migration-safety-check/SKILL.md +117 -0
  341. package/templates/default/locales/ko/.mustflow/skills/multi-agent-work-coordination/SKILL.md +259 -0
  342. package/templates/default/locales/ko/.mustflow/skills/null-object-pattern/SKILL.md +196 -0
  343. package/templates/default/locales/ko/.mustflow/skills/pattern-scout/SKILL.md +110 -0
  344. package/templates/default/locales/ko/.mustflow/skills/performance-budget-check/SKILL.md +121 -0
  345. package/templates/default/locales/ko/.mustflow/skills/project-context-authoring/SKILL.md +107 -0
  346. package/templates/default/locales/ko/.mustflow/skills/pure-core-imperative-shell/SKILL.md +212 -0
  347. package/templates/default/locales/ko/.mustflow/skills/readme-authoring/SKILL.md +115 -0
  348. package/templates/default/locales/ko/.mustflow/skills/repo-improvement-loop/SKILL.md +150 -0
  349. package/templates/default/locales/ko/.mustflow/skills/repro-first-debug/SKILL.md +112 -0
  350. package/templates/default/locales/ko/.mustflow/skills/requirement-regression-guard/SKILL.md +152 -0
  351. package/templates/default/locales/ko/.mustflow/skills/result-option/SKILL.md +186 -0
  352. package/templates/default/locales/ko/.mustflow/skills/security-privacy-review/SKILL.md +116 -0
  353. package/templates/default/locales/ko/.mustflow/skills/security-regression-tests/SKILL.md +131 -0
  354. package/templates/default/locales/ko/.mustflow/skills/skill-authoring/SKILL.md +110 -0
  355. package/templates/default/locales/ko/.mustflow/skills/source-freshness-check/SKILL.md +111 -0
  356. package/templates/default/locales/ko/.mustflow/skills/state-machine-pattern/SKILL.md +214 -0
  357. package/templates/default/locales/ko/.mustflow/skills/strategy-pattern/SKILL.md +215 -0
  358. package/templates/default/locales/ko/.mustflow/skills/structure-discovery-gate/SKILL.md +159 -0
  359. package/templates/default/locales/ko/.mustflow/skills/test-maintenance/SKILL.md +130 -0
  360. package/templates/default/locales/ko/.mustflow/skills/ui-quality-gate/SKILL.md +117 -0
  361. package/templates/default/locales/ko/.mustflow/skills/visual-review-artifact/SKILL.md +127 -0
  362. package/templates/default/locales/ko/.mustflow/skills/visual-review-artifact/assets/review-template.html +286 -0
  363. package/templates/default/locales/ko/.mustflow/skills/visual-review-artifact/resources.toml +7 -0
  364. package/templates/default/locales/ko/.mustflow/skills/web-asset-optimization/SKILL.md +108 -0
  365. package/templates/default/locales/ko/AGENTS.md +85 -0
  366. package/templates/default/locales/zh/.mustflow/context/INDEX.md +39 -0
  367. package/templates/default/locales/zh/.mustflow/context/PROJECT.md +64 -0
  368. package/templates/default/locales/zh/.mustflow/docs/agent-workflow.md +310 -0
  369. package/templates/default/locales/zh/.mustflow/skills/INDEX.md +78 -0
  370. package/templates/default/locales/zh/.mustflow/skills/adapter-boundary/SKILL.md +193 -0
  371. package/templates/default/locales/zh/.mustflow/skills/artifact-integrity-check/SKILL.md +114 -0
  372. package/templates/default/locales/zh/.mustflow/skills/behavior-preserving-refactor/SKILL.md +182 -0
  373. package/templates/default/locales/zh/.mustflow/skills/code-review/SKILL.md +115 -0
  374. package/templates/default/locales/zh/.mustflow/skills/codebase-orientation/SKILL.md +115 -0
  375. package/templates/default/locales/zh/.mustflow/skills/command-pattern/SKILL.md +247 -0
  376. package/templates/default/locales/zh/.mustflow/skills/composition-over-inheritance/SKILL.md +176 -0
  377. package/templates/default/locales/zh/.mustflow/skills/contract-sync-check/SKILL.md +116 -0
  378. package/templates/default/locales/zh/.mustflow/skills/date-number-audit/SKILL.md +116 -0
  379. package/templates/default/locales/zh/.mustflow/skills/dependency-injection/SKILL.md +161 -0
  380. package/templates/default/locales/zh/.mustflow/skills/dependency-reality-check/SKILL.md +115 -0
  381. package/templates/default/locales/zh/.mustflow/skills/diff-risk-review/SKILL.md +136 -0
  382. package/templates/default/locales/zh/.mustflow/skills/docs-prose-review/SKILL.md +119 -0
  383. package/templates/default/locales/zh/.mustflow/skills/docs-update/SKILL.md +97 -0
  384. package/templates/default/locales/zh/.mustflow/skills/external-prompt-injection-defense/SKILL.md +116 -0
  385. package/templates/default/locales/zh/.mustflow/skills/facade-pattern/SKILL.md +210 -0
  386. package/templates/default/locales/zh/.mustflow/skills/failure-triage/SKILL.md +96 -0
  387. package/templates/default/locales/zh/.mustflow/skills/instruction-conflict-scope-check/SKILL.md +118 -0
  388. package/templates/default/locales/zh/.mustflow/skills/line-ending-hygiene/SKILL.md +111 -0
  389. package/templates/default/locales/zh/.mustflow/skills/migration-safety-check/SKILL.md +117 -0
  390. package/templates/default/locales/zh/.mustflow/skills/multi-agent-work-coordination/SKILL.md +260 -0
  391. package/templates/default/locales/zh/.mustflow/skills/null-object-pattern/SKILL.md +196 -0
  392. package/templates/default/locales/zh/.mustflow/skills/pattern-scout/SKILL.md +110 -0
  393. package/templates/default/locales/zh/.mustflow/skills/performance-budget-check/SKILL.md +121 -0
  394. package/templates/default/locales/zh/.mustflow/skills/project-context-authoring/SKILL.md +107 -0
  395. package/templates/default/locales/zh/.mustflow/skills/pure-core-imperative-shell/SKILL.md +212 -0
  396. package/templates/default/locales/zh/.mustflow/skills/readme-authoring/SKILL.md +115 -0
  397. package/templates/default/locales/zh/.mustflow/skills/repo-improvement-loop/SKILL.md +150 -0
  398. package/templates/default/locales/zh/.mustflow/skills/repro-first-debug/SKILL.md +112 -0
  399. package/templates/default/locales/zh/.mustflow/skills/requirement-regression-guard/SKILL.md +152 -0
  400. package/templates/default/locales/zh/.mustflow/skills/result-option/SKILL.md +186 -0
  401. package/templates/default/locales/zh/.mustflow/skills/security-privacy-review/SKILL.md +116 -0
  402. package/templates/default/locales/zh/.mustflow/skills/security-regression-tests/SKILL.md +131 -0
  403. package/templates/default/locales/zh/.mustflow/skills/skill-authoring/SKILL.md +110 -0
  404. package/templates/default/locales/zh/.mustflow/skills/source-freshness-check/SKILL.md +111 -0
  405. package/templates/default/locales/zh/.mustflow/skills/state-machine-pattern/SKILL.md +214 -0
  406. package/templates/default/locales/zh/.mustflow/skills/strategy-pattern/SKILL.md +215 -0
  407. package/templates/default/locales/zh/.mustflow/skills/structure-discovery-gate/SKILL.md +159 -0
  408. package/templates/default/locales/zh/.mustflow/skills/test-maintenance/SKILL.md +122 -0
  409. package/templates/default/locales/zh/.mustflow/skills/ui-quality-gate/SKILL.md +117 -0
  410. package/templates/default/locales/zh/.mustflow/skills/visual-review-artifact/SKILL.md +127 -0
  411. package/templates/default/locales/zh/.mustflow/skills/visual-review-artifact/assets/review-template.html +286 -0
  412. package/templates/default/locales/zh/.mustflow/skills/visual-review-artifact/resources.toml +7 -0
  413. package/templates/default/locales/zh/.mustflow/skills/web-asset-optimization/SKILL.md +108 -0
  414. package/templates/default/locales/zh/AGENTS.md +86 -0
  415. package/templates/default/manifest.toml +339 -0
@@ -0,0 +1,166 @@
1
+ import { printUsageError, renderHelp } from '../lib/cli-output.js';
2
+ import { t } from '../lib/i18n.js';
3
+ import { searchLocalIndex } from '../lib/local-index.js';
4
+ import { resolveMustflowRoot } from '../lib/project-root.js';
5
+ export function getSearchHelp(lang = 'en') {
6
+ return renderHelp({
7
+ usage: 'mf search <query> [options]',
8
+ summary: t(lang, 'search.help.summary'),
9
+ options: [
10
+ {
11
+ label: '--limit <number>',
12
+ description: t(lang, 'search.help.option.limit'),
13
+ },
14
+ {
15
+ label: '--scope <workflow|source|all>',
16
+ description: t(lang, 'search.help.option.scope'),
17
+ },
18
+ { label: '--json', description: t(lang, 'cli.option.json') },
19
+ { label: '-h, --help', description: t(lang, 'cli.option.help') },
20
+ ],
21
+ examples: [
22
+ 'mf index',
23
+ 'mf index --source',
24
+ 'mf search mustflow_check',
25
+ 'mf search "role mapping" --scope source',
26
+ 'mf search test --limit 5',
27
+ ],
28
+ exitCodes: [
29
+ {
30
+ label: '0',
31
+ description: t(lang, 'search.help.exit.ok'),
32
+ },
33
+ {
34
+ label: '1',
35
+ description: t(lang, 'search.help.exit.fail'),
36
+ },
37
+ ],
38
+ }, lang);
39
+ }
40
+ function parseSearchOptions(args) {
41
+ const queryParts = [];
42
+ let limit = 10;
43
+ let scope = 'workflow';
44
+ let json = false;
45
+ for (let index = 0; index < args.length; index += 1) {
46
+ const arg = args[index];
47
+ if (!arg) {
48
+ continue;
49
+ }
50
+ if (arg === '--json') {
51
+ json = true;
52
+ continue;
53
+ }
54
+ if (arg === '--limit') {
55
+ const rawLimit = args[index + 1];
56
+ if (!rawLimit || rawLimit.startsWith('-')) {
57
+ return { query: '', limit, scope, json, error: { key: 'search.error.missingLimit' } };
58
+ }
59
+ const parsedLimit = Number.parseInt(rawLimit, 10);
60
+ if (!Number.isInteger(parsedLimit) || parsedLimit < 1 || parsedLimit > 50) {
61
+ return { query: '', limit, scope, json, error: { key: 'search.error.invalidLimit' } };
62
+ }
63
+ limit = parsedLimit;
64
+ index += 1;
65
+ continue;
66
+ }
67
+ if (arg.startsWith('--limit=')) {
68
+ const rawLimit = arg.slice('--limit='.length);
69
+ const parsedLimit = Number.parseInt(rawLimit, 10);
70
+ if (!Number.isInteger(parsedLimit) || parsedLimit < 1 || parsedLimit > 50) {
71
+ return { query: '', limit, scope, json, error: { key: 'search.error.invalidLimit' } };
72
+ }
73
+ limit = parsedLimit;
74
+ continue;
75
+ }
76
+ if (arg === '--scope') {
77
+ const rawScope = args[index + 1];
78
+ if (!rawScope || rawScope.startsWith('-')) {
79
+ return { query: '', limit, scope, json, error: { key: 'search.error.missingScope' } };
80
+ }
81
+ if (!isSearchScope(rawScope)) {
82
+ return {
83
+ query: '',
84
+ limit,
85
+ scope,
86
+ json,
87
+ error: { key: 'search.error.invalidScope', params: { scope: rawScope } },
88
+ };
89
+ }
90
+ scope = rawScope;
91
+ index += 1;
92
+ continue;
93
+ }
94
+ if (arg.startsWith('--scope=')) {
95
+ const rawScope = arg.slice('--scope='.length);
96
+ if (!isSearchScope(rawScope)) {
97
+ return {
98
+ query: '',
99
+ limit,
100
+ scope,
101
+ json,
102
+ error: { key: 'search.error.invalidScope', params: { scope: rawScope } },
103
+ };
104
+ }
105
+ scope = rawScope;
106
+ continue;
107
+ }
108
+ if (arg.startsWith('-')) {
109
+ return { query: '', limit, scope, json, error: { key: 'cli.error.unknownOption', params: { option: arg } } };
110
+ }
111
+ queryParts.push(arg);
112
+ }
113
+ const query = queryParts.join(' ').trim();
114
+ if (query.length === 0) {
115
+ return { query, limit, scope, json, error: { key: 'search.error.missingQuery' } };
116
+ }
117
+ return { query, limit, scope, json };
118
+ }
119
+ function isSearchScope(value) {
120
+ return value === 'workflow' || value === 'source' || value === 'all';
121
+ }
122
+ function renderSearchSummary(result, lang) {
123
+ const lines = [
124
+ t(lang, 'search.title'),
125
+ `${t(lang, 'label.query')}: ${result.query}`,
126
+ `${t(lang, 'label.scope')}: ${result.scope}`,
127
+ `${t(lang, 'label.results')}: ${result.result_count}`,
128
+ ];
129
+ for (const item of result.results) {
130
+ const target = item.path ?? item.name ?? item.title ?? item.kind;
131
+ const title = item.title && item.title !== target ? ` — ${item.title}` : '';
132
+ const line = item.line_start ? `${target}:${item.line_start}` : target;
133
+ lines.push(`- [${item.kind}] ${line}${title}`);
134
+ lines.push(` ${item.authority_label}; navigation_only=${String(item.navigation_only)}`);
135
+ lines.push(` ${item.match}`);
136
+ }
137
+ if (result.result_count === 0) {
138
+ lines.push(t(lang, 'search.noMatches'));
139
+ }
140
+ return lines.join('\n');
141
+ }
142
+ export async function runSearch(args, reporter, lang = 'en') {
143
+ if (args.includes('--help') || args.includes('-h')) {
144
+ reporter.stdout(getSearchHelp(lang));
145
+ return 0;
146
+ }
147
+ const options = parseSearchOptions(args);
148
+ if (options.error) {
149
+ printUsageError(reporter, t(lang, options.error.key, options.error.params), 'mf search --help', getSearchHelp(lang), lang);
150
+ return 1;
151
+ }
152
+ try {
153
+ const result = await searchLocalIndex(resolveMustflowRoot(), options.query, { limit: options.limit, scope: options.scope });
154
+ if (options.json) {
155
+ reporter.stdout(JSON.stringify(result, null, 2));
156
+ return 0;
157
+ }
158
+ reporter.stdout(renderSearchSummary(result, lang));
159
+ return 0;
160
+ }
161
+ catch (error) {
162
+ const message = error instanceof Error ? error.message : String(error);
163
+ reporter.stderr(t(lang, 'cli.error.prefix', { message }));
164
+ return 1;
165
+ }
166
+ }
@@ -0,0 +1,65 @@
1
+ import { existsSync } from 'node:fs';
2
+ import path from 'node:path';
3
+ import { printUsageError, renderHelp } from '../lib/cli-output.js';
4
+ import { t } from '../lib/i18n.js';
5
+ import { inspectManifestLock } from '../lib/manifest-lock.js';
6
+ import { resolveMustflowRoot } from '../lib/project-root.js';
7
+ export function getStatusHelp(lang = 'en') {
8
+ return renderHelp({
9
+ usage: 'mf status [options]',
10
+ summary: t(lang, 'status.help.summary'),
11
+ options: [
12
+ { label: '--json', description: t(lang, 'cli.option.json') },
13
+ { label: '-h, --help', description: t(lang, 'cli.option.help') },
14
+ ],
15
+ examples: ['mf status', 'mf status --json'],
16
+ exitCodes: [
17
+ { label: '0', description: t(lang, 'status.help.exit.ok') },
18
+ { label: '1', description: t(lang, 'cli.common.invalidInput') },
19
+ ],
20
+ }, lang);
21
+ }
22
+ function hasInstalledEntrypoints(projectRoot) {
23
+ return existsSync(path.join(projectRoot, 'AGENTS.md')) && existsSync(path.join(projectRoot, '.mustflow'));
24
+ }
25
+ function getStatusSnapshot(projectRoot) {
26
+ const inspection = inspectManifestLock(projectRoot);
27
+ const lock = inspection.readResult.kind === 'present' ? inspection.readResult.lock : undefined;
28
+ return {
29
+ installed: hasInstalledEntrypoints(projectRoot),
30
+ manifestLock: inspection.readResult.kind,
31
+ trackedFiles: lock?.files.length ?? 0,
32
+ changedFiles: inspection.changedFiles,
33
+ missingFiles: inspection.missingFiles,
34
+ issues: inspection.issues,
35
+ template: lock ? { id: lock.templateId, version: lock.templateVersion } : null,
36
+ };
37
+ }
38
+ export function runStatus(args, reporter, lang = 'en') {
39
+ if (args.includes('--help') || args.includes('-h')) {
40
+ reporter.stdout(getStatusHelp(lang));
41
+ return 0;
42
+ }
43
+ const supported = new Set(['--json']);
44
+ const unsupported = args.filter((arg) => !supported.has(arg));
45
+ if (unsupported.length > 0) {
46
+ printUsageError(reporter, t(lang, 'cli.error.unknownOption', { option: unsupported[0] }), 'mf status --help', getStatusHelp(lang), lang);
47
+ return 1;
48
+ }
49
+ const projectRoot = resolveMustflowRoot();
50
+ const status = getStatusSnapshot(projectRoot);
51
+ if (args.includes('--json')) {
52
+ reporter.stdout(JSON.stringify(status, null, 2));
53
+ return 0;
54
+ }
55
+ reporter.stdout(t(lang, 'status.title'));
56
+ reporter.stdout(`${t(lang, 'label.installed')}: ${status.installed ? 'yes' : 'no'}`);
57
+ reporter.stdout(`${t(lang, 'label.manifestLock')}: ${status.manifestLock}`);
58
+ reporter.stdout(`${t(lang, 'label.trackedFiles')}: ${status.trackedFiles}`);
59
+ reporter.stdout(`${t(lang, 'label.changedFiles')}: ${status.changedFiles.length}`);
60
+ reporter.stdout(`${t(lang, 'label.missingFiles')}: ${status.missingFiles.length}`);
61
+ for (const issue of status.issues) {
62
+ reporter.stdout(`- ${issue.replace(/^Lock hash mismatch: /, '').replace(/^Locked file missing: /, '')}`);
63
+ }
64
+ return 0;
65
+ }
@@ -0,0 +1,443 @@
1
+ import { createHash } from 'node:crypto';
2
+ import { copyFileSync, existsSync, mkdirSync } from 'node:fs';
3
+ import path from 'node:path';
4
+ import { ensureFileTargetInsideWithoutSymlinks, ensureInside, writeUtf8FileInsideWithoutSymlinks, } from '../lib/filesystem.js';
5
+ import { MANIFEST_LOCK_RELATIVE_PATH, readManifestLock, sha256File } from '../lib/manifest-lock.js';
6
+ import { printUsageError, renderHelp } from '../lib/cli-output.js';
7
+ import { t } from '../lib/i18n.js';
8
+ import { resolveMustflowRoot } from '../lib/project-root.js';
9
+ import { getDefaultTemplate, getTemplateFiles } from '../lib/templates.js';
10
+ import { readTomlFile, stringifyToml } from '../lib/toml.js';
11
+ const UPDATE_SCHEMA_VERSION = '1';
12
+ const CUSTOMIZED_LOCK_ACTION = 'customized';
13
+ const UPDATE_POLICY = {
14
+ baseline: 'manifest_lock_content_hash',
15
+ allowed_apply_actions: ['update', 'create'],
16
+ blocking_actions: ['blocked-local-change', 'manual-review'],
17
+ dry_run_writes_files: false,
18
+ backup_path_pattern: '.mustflow/backups/<timestamp>/',
19
+ never_overwrite_local_changes: true,
20
+ writes_only_template_manifest_paths: true,
21
+ };
22
+ export function getUpdateHelp(lang = 'en') {
23
+ return renderHelp({
24
+ usage: 'mf update (--dry-run|--apply) [options]',
25
+ summary: t(lang, 'update.help.summary'),
26
+ options: [
27
+ { label: '--dry-run', description: t(lang, 'update.help.option.dryRun') },
28
+ {
29
+ label: '--apply',
30
+ description: t(lang, 'update.help.option.apply'),
31
+ },
32
+ { label: '--json', description: t(lang, 'cli.option.json') },
33
+ { label: '-h, --help', description: t(lang, 'cli.option.help') },
34
+ ],
35
+ examples: ['mf update --dry-run', 'mf update --dry-run --json', 'mf update --apply'],
36
+ exitCodes: [
37
+ {
38
+ label: '0',
39
+ description: t(lang, 'update.help.exit.ok'),
40
+ },
41
+ {
42
+ label: '1',
43
+ description: t(lang, 'update.help.exit.fail'),
44
+ },
45
+ ],
46
+ }, lang);
47
+ }
48
+ function byRelativePath(files) {
49
+ return new Map(files.map((file) => [file.relativePath, file]));
50
+ }
51
+ function sha256Text(content) {
52
+ return `sha256:${createHash('sha256').update(content).digest('hex')}`;
53
+ }
54
+ function templateFileHash(source) {
55
+ return source.content === undefined ? sha256File(source.sourcePath) : sha256Text(source.content);
56
+ }
57
+ function writeTemplateFile(projectRoot, source, targetPath) {
58
+ if (source.content !== undefined) {
59
+ writeUtf8FileInsideWithoutSymlinks(projectRoot, targetPath, source.content);
60
+ return;
61
+ }
62
+ ensureFileTargetInsideWithoutSymlinks(projectRoot, targetPath, { allowMissingLeaf: true });
63
+ mkdirSync(path.dirname(targetPath), { recursive: true });
64
+ copyFileSync(source.sourcePath, targetPath);
65
+ }
66
+ function templateTargetSafetyIssue(projectRoot, targetPath, allowMissingLeaf) {
67
+ try {
68
+ ensureFileTargetInsideWithoutSymlinks(projectRoot, targetPath, { allowMissingLeaf });
69
+ return undefined;
70
+ }
71
+ catch (error) {
72
+ return error instanceof Error ? error.message : String(error);
73
+ }
74
+ }
75
+ export function planUpdate(projectRoot) {
76
+ const lockResult = readManifestLock(projectRoot);
77
+ if (lockResult.kind === 'missing') {
78
+ return { items: [], error: `Missing ${MANIFEST_LOCK_RELATIVE_PATH}` };
79
+ }
80
+ if (lockResult.kind === 'invalid') {
81
+ return { items: [], error: `Invalid manifest lock: ${lockResult.message}` };
82
+ }
83
+ let template;
84
+ try {
85
+ template = getDefaultTemplate();
86
+ }
87
+ catch (error) {
88
+ return { items: [], error: error instanceof Error ? error.message : String(error) };
89
+ }
90
+ const selectedLocale = lockResult.lock.templateLocale ?? template.manifest.defaultLocale;
91
+ const selectedProfile = lockResult.lock.templateProfile ?? template.manifest.defaultProfile;
92
+ const templateFiles = getTemplateFiles(template, selectedLocale, selectedProfile);
93
+ const lockedFiles = byRelativePath(lockResult.lock.files);
94
+ const items = [];
95
+ for (const source of templateFiles) {
96
+ const targetPath = path.join(projectRoot, source.relativePath);
97
+ const lockedFile = lockedFiles.get(source.relativePath);
98
+ ensureInside(template.templateRoot, source.sourcePath);
99
+ ensureInside(projectRoot, targetPath);
100
+ const unsafeTargetReason = templateTargetSafetyIssue(projectRoot, targetPath, true);
101
+ if (unsafeTargetReason) {
102
+ items.push({
103
+ relativePath: source.relativePath,
104
+ sourceKind: source.sourceKind,
105
+ action: 'blocked-local-change',
106
+ reason: unsafeTargetReason,
107
+ });
108
+ continue;
109
+ }
110
+ if (!existsSync(targetPath)) {
111
+ if (lockedFile) {
112
+ items.push({
113
+ relativePath: source.relativePath,
114
+ sourceKind: source.sourceKind,
115
+ action: 'blocked-local-change',
116
+ reason: 'target file is missing but tracked by the manifest lock',
117
+ });
118
+ continue;
119
+ }
120
+ items.push({
121
+ relativePath: source.relativePath,
122
+ sourceKind: source.sourceKind,
123
+ action: 'create',
124
+ reason: 'target file is missing',
125
+ });
126
+ continue;
127
+ }
128
+ const currentHash = sha256File(targetPath);
129
+ const templateHash = templateFileHash(source);
130
+ if (!lockedFile && currentHash !== templateHash) {
131
+ items.push({
132
+ relativePath: source.relativePath,
133
+ sourceKind: source.sourceKind,
134
+ action: 'blocked-local-change',
135
+ reason: 'target file exists but is not tracked by the manifest lock',
136
+ });
137
+ continue;
138
+ }
139
+ if (lockedFile && currentHash !== lockedFile.contentHash) {
140
+ items.push({
141
+ relativePath: source.relativePath,
142
+ sourceKind: source.sourceKind,
143
+ action: 'blocked-local-change',
144
+ reason: 'current file differs from the manifest lock baseline',
145
+ });
146
+ continue;
147
+ }
148
+ if (lockedFile?.lastAction === CUSTOMIZED_LOCK_ACTION && currentHash !== templateHash) {
149
+ items.push({
150
+ relativePath: source.relativePath,
151
+ sourceKind: source.sourceKind,
152
+ action: 'unchanged',
153
+ reason: 'manifest lock marks this file as customized and current file matches that baseline',
154
+ });
155
+ continue;
156
+ }
157
+ if (lockedFile?.source === 'managed_block' && currentHash !== templateHash) {
158
+ items.push({
159
+ relativePath: source.relativePath,
160
+ sourceKind: source.sourceKind,
161
+ action: 'manual-review',
162
+ reason: 'managed block requires a block-level manifest baseline',
163
+ });
164
+ continue;
165
+ }
166
+ if (currentHash !== templateHash) {
167
+ items.push({
168
+ relativePath: source.relativePath,
169
+ sourceKind: source.sourceKind,
170
+ action: 'update',
171
+ reason: 'template content differs from current file',
172
+ });
173
+ continue;
174
+ }
175
+ items.push({
176
+ relativePath: source.relativePath,
177
+ sourceKind: source.sourceKind,
178
+ action: 'unchanged',
179
+ reason: 'current file matches the bundled template',
180
+ });
181
+ }
182
+ return { items };
183
+ }
184
+ function printItems(title, items, reporter) {
185
+ reporter.stdout(`${title}: ${items.length}`);
186
+ for (const item of items) {
187
+ reporter.stdout(`- ${item.relativePath} (${item.reason})`);
188
+ }
189
+ }
190
+ export function summarizePlan(items) {
191
+ return {
192
+ blockedLocalChanges: items.filter((item) => item.action === 'blocked-local-change').length,
193
+ manualReview: items.filter((item) => item.action === 'manual-review').length,
194
+ wouldUpdate: items.filter((item) => item.action === 'update').length,
195
+ wouldCreate: items.filter((item) => item.action === 'create').length,
196
+ unchanged: items.filter((item) => item.action === 'unchanged').length,
197
+ };
198
+ }
199
+ function isMutableTable(value) {
200
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
201
+ }
202
+ function fileActionToLockAction(action) {
203
+ return action === 'create' ? 'created' : 'updated';
204
+ }
205
+ function readInstalledTemplateSelection(projectRoot) {
206
+ const lockResult = readManifestLock(projectRoot);
207
+ return lockResult.kind === 'present'
208
+ ? { locale: lockResult.lock.templateLocale, profile: lockResult.lock.templateProfile }
209
+ : {};
210
+ }
211
+ function copyTemplateFile(projectRoot, relativePath) {
212
+ const template = getDefaultTemplate();
213
+ const selection = readInstalledTemplateSelection(projectRoot);
214
+ const source = getTemplateFiles(template, selection.locale ?? template.manifest.defaultLocale, selection.profile ?? template.manifest.defaultProfile).find((file) => file.relativePath === relativePath);
215
+ const targetPath = path.join(projectRoot, relativePath);
216
+ if (!source) {
217
+ throw new Error(`Template source missing for ${relativePath}`);
218
+ }
219
+ ensureInside(template.templateRoot, source.sourcePath);
220
+ ensureInside(projectRoot, targetPath);
221
+ ensureFileTargetInsideWithoutSymlinks(projectRoot, targetPath, { allowMissingLeaf: true });
222
+ writeTemplateFile(projectRoot, source, targetPath);
223
+ }
224
+ function backupUpdateFiles(projectRoot, items, reporter, lang) {
225
+ const updateItems = items.filter((item) => item.action === 'update');
226
+ if (updateItems.length === 0) {
227
+ return;
228
+ }
229
+ const timestamp = new Date().toISOString().replace(/[:.]/g, '-');
230
+ const backupRoot = path.join(projectRoot, '.mustflow', 'backups', timestamp);
231
+ for (const item of updateItems) {
232
+ const sourcePath = path.join(projectRoot, item.relativePath);
233
+ const backupPath = path.join(backupRoot, item.relativePath);
234
+ ensureInside(projectRoot, sourcePath);
235
+ ensureInside(backupRoot, backupPath);
236
+ ensureFileTargetInsideWithoutSymlinks(projectRoot, sourcePath);
237
+ ensureFileTargetInsideWithoutSymlinks(projectRoot, backupPath, { allowMissingLeaf: true });
238
+ mkdirSync(path.dirname(backupPath), { recursive: true });
239
+ copyFileSync(sourcePath, backupPath);
240
+ }
241
+ reporter.stdout(t(lang, 'update.backup.files', {
242
+ count: updateItems.length,
243
+ fileWord: t(lang, updateItems.length === 1 ? 'init.fileWord.singular' : 'init.fileWord.plural'),
244
+ path: backupRoot,
245
+ }));
246
+ }
247
+ function updateManifestLockAfterApply(projectRoot, appliedItems) {
248
+ if (appliedItems.length === 0) {
249
+ return;
250
+ }
251
+ const lockPath = path.join(projectRoot, MANIFEST_LOCK_RELATIVE_PATH);
252
+ ensureInside(projectRoot, lockPath);
253
+ ensureFileTargetInsideWithoutSymlinks(projectRoot, lockPath);
254
+ const parsed = readTomlFile(lockPath);
255
+ if (!isMutableTable(parsed)) {
256
+ throw new Error(`Invalid manifest lock: ${MANIFEST_LOCK_RELATIVE_PATH} must contain a TOML table`);
257
+ }
258
+ const template = getDefaultTemplate();
259
+ const templateTable = isMutableTable(parsed.template) ? parsed.template : {};
260
+ templateTable.id = template.manifest.id;
261
+ templateTable.version = template.manifest.version;
262
+ parsed.template = templateTable;
263
+ const filesTable = isMutableTable(parsed.files) ? parsed.files : {};
264
+ for (const item of appliedItems) {
265
+ const targetPath = path.join(projectRoot, item.relativePath);
266
+ ensureInside(projectRoot, targetPath);
267
+ ensureFileTargetInsideWithoutSymlinks(projectRoot, targetPath);
268
+ const existing = filesTable[item.relativePath];
269
+ const existingTable = isMutableTable(existing) ? existing : {};
270
+ filesTable[item.relativePath] = {
271
+ source: typeof existingTable.source === 'string'
272
+ ? existingTable.source
273
+ : item.sourceKind === 'locale'
274
+ ? 'template_locale'
275
+ : 'template_common',
276
+ last_action: fileActionToLockAction(item.action),
277
+ content_hash: sha256File(targetPath),
278
+ };
279
+ }
280
+ parsed.files = filesTable;
281
+ writeUtf8FileInsideWithoutSymlinks(projectRoot, lockPath, stringifyToml(parsed));
282
+ }
283
+ function applyUpdate(projectRoot, items, reporter, lang) {
284
+ let created = 0;
285
+ let updated = 0;
286
+ const appliedItems = [];
287
+ backupUpdateFiles(projectRoot, items, reporter, lang);
288
+ for (const item of items) {
289
+ if (item.action !== 'create' && item.action !== 'update') {
290
+ continue;
291
+ }
292
+ copyTemplateFile(projectRoot, item.relativePath);
293
+ appliedItems.push(item);
294
+ if (item.action === 'create') {
295
+ created += 1;
296
+ reporter.stdout(t(lang, 'update.action.created', { path: item.relativePath }));
297
+ }
298
+ else {
299
+ updated += 1;
300
+ reporter.stdout(t(lang, 'update.action.updated', { path: item.relativePath }));
301
+ }
302
+ }
303
+ updateManifestLockAfterApply(projectRoot, appliedItems);
304
+ if (appliedItems.length > 0) {
305
+ reporter.stdout(t(lang, 'update.action.wrote', { path: MANIFEST_LOCK_RELATIVE_PATH }));
306
+ }
307
+ return {
308
+ created,
309
+ updated,
310
+ wroteFiles: appliedItems.length > 0,
311
+ };
312
+ }
313
+ function planOutput(items, error, wroteFiles) {
314
+ const summary = summarizePlan(items);
315
+ return {
316
+ schema_version: UPDATE_SCHEMA_VERSION,
317
+ command: 'update',
318
+ mode: 'unspecified',
319
+ policy: UPDATE_POLICY,
320
+ ok: !error && summary.blockedLocalChanges === 0 && summary.manualReview === 0,
321
+ wroteFiles,
322
+ summary,
323
+ items,
324
+ ...(error ? { error } : {}),
325
+ };
326
+ }
327
+ function withMode(output, mode) {
328
+ return {
329
+ ...output,
330
+ mode,
331
+ };
332
+ }
333
+ function getRequestedMode(wantsDryRun, wantsApply) {
334
+ if (wantsDryRun && !wantsApply) {
335
+ return 'dry-run';
336
+ }
337
+ if (wantsApply && !wantsDryRun) {
338
+ return 'apply';
339
+ }
340
+ return 'unspecified';
341
+ }
342
+ function printPolicy(reporter, lang) {
343
+ reporter.stdout(t(lang, 'update.policy.title'));
344
+ reporter.stdout(`- ${t(lang, 'update.policy.baseline')}: ${UPDATE_POLICY.baseline}`);
345
+ reporter.stdout(`- ${t(lang, 'update.policy.applyActions')}: ${UPDATE_POLICY.allowed_apply_actions.join(', ')}`);
346
+ reporter.stdout(`- ${t(lang, 'update.policy.blockingActions')}: ${UPDATE_POLICY.blocking_actions.join(', ')}`);
347
+ reporter.stdout(`- ${t(lang, 'update.policy.backupPath')}: ${UPDATE_POLICY.backup_path_pattern}`);
348
+ }
349
+ function printPlan(output, reporter, lang) {
350
+ const blocked = output.items.filter((item) => item.action === 'blocked-local-change');
351
+ const manualReview = output.items.filter((item) => item.action === 'manual-review');
352
+ const updates = output.items.filter((item) => item.action === 'update');
353
+ const creates = output.items.filter((item) => item.action === 'create');
354
+ reporter.stdout(t(lang, 'update.plan.title'));
355
+ printPolicy(reporter, lang);
356
+ printItems(t(lang, 'update.plan.blocked'), blocked, reporter);
357
+ printItems(t(lang, 'update.plan.manualReview'), manualReview, reporter);
358
+ printItems(t(lang, 'update.plan.wouldUpdate'), updates, reporter);
359
+ printItems(t(lang, 'update.plan.wouldCreate'), creates, reporter);
360
+ if (blocked.length === 0 && manualReview.length === 0 && updates.length === 0 && creates.length === 0) {
361
+ reporter.stdout(t(lang, 'update.plan.noUpdates'));
362
+ }
363
+ }
364
+ export function runUpdate(args, reporter, lang = 'en') {
365
+ if (args.includes('--help') || args.includes('-h')) {
366
+ reporter.stdout(getUpdateHelp(lang));
367
+ return 0;
368
+ }
369
+ const supported = new Set(['--dry-run', '--apply', '--json']);
370
+ const unsupported = args.filter((arg) => !supported.has(arg));
371
+ const wantsJson = args.includes('--json');
372
+ const wantsDryRun = args.includes('--dry-run');
373
+ const wantsApply = args.includes('--apply');
374
+ const requestedMode = getRequestedMode(wantsDryRun, wantsApply);
375
+ if (unsupported.length > 0) {
376
+ printUsageError(reporter, t(lang, 'cli.error.unknownOption', { option: unsupported[0] }), 'mf update --help', getUpdateHelp(lang), lang);
377
+ return 1;
378
+ }
379
+ if (wantsDryRun && wantsApply) {
380
+ const error = t(lang, 'update.error.cannotCombineModes');
381
+ if (wantsJson) {
382
+ reporter.stdout(JSON.stringify(withMode(planOutput([], error, false), requestedMode), null, 2));
383
+ return 1;
384
+ }
385
+ printUsageError(reporter, error, 'mf update --help', getUpdateHelp(lang), lang);
386
+ return 1;
387
+ }
388
+ if (!wantsDryRun && !wantsApply) {
389
+ const error = t(lang, 'update.error.missingMode');
390
+ if (wantsJson) {
391
+ reporter.stdout(JSON.stringify(withMode(planOutput([], error, false), requestedMode), null, 2));
392
+ return 1;
393
+ }
394
+ printUsageError(reporter, error, 'mf update --help', getUpdateHelp(lang), lang);
395
+ return 1;
396
+ }
397
+ const projectRoot = resolveMustflowRoot();
398
+ const plan = planUpdate(projectRoot);
399
+ if (plan.error) {
400
+ if (wantsJson) {
401
+ reporter.stdout(JSON.stringify(withMode(planOutput(plan.items, plan.error, false), requestedMode), null, 2));
402
+ return 1;
403
+ }
404
+ reporter.stderr(plan.error);
405
+ return 1;
406
+ }
407
+ const dryRunOutput = withMode(planOutput(plan.items, undefined, false), requestedMode);
408
+ if (wantsDryRun) {
409
+ if (wantsJson) {
410
+ reporter.stdout(JSON.stringify(dryRunOutput, null, 2));
411
+ return dryRunOutput.ok ? 0 : 1;
412
+ }
413
+ printPlan(dryRunOutput, reporter, lang);
414
+ reporter.stdout(t(lang, 'update.plan.noFilesWritten'));
415
+ return dryRunOutput.ok ? 0 : 1;
416
+ }
417
+ if (!dryRunOutput.ok) {
418
+ if (wantsJson) {
419
+ reporter.stdout(JSON.stringify(dryRunOutput, null, 2));
420
+ return 1;
421
+ }
422
+ printPlan(dryRunOutput, reporter, lang);
423
+ reporter.stdout(t(lang, 'update.plan.noFilesWritten'));
424
+ return 1;
425
+ }
426
+ if (wantsJson) {
427
+ const applicableItems = plan.items.filter((item) => item.action === 'create' || item.action === 'update');
428
+ const applyResult = applyUpdate(projectRoot, applicableItems, {
429
+ stdout: () => undefined,
430
+ stderr: (message) => reporter.stderr(message),
431
+ }, lang);
432
+ reporter.stdout(JSON.stringify(withMode(planOutput(plan.items, undefined, applyResult.wroteFiles), 'apply'), null, 2));
433
+ return 0;
434
+ }
435
+ const applyResult = applyUpdate(projectRoot, plan.items, reporter, lang);
436
+ if (!applyResult.wroteFiles) {
437
+ reporter.stdout(t(lang, 'update.plan.noUpdates'));
438
+ reporter.stdout(t(lang, 'update.plan.noFilesWritten'));
439
+ return 0;
440
+ }
441
+ reporter.stdout(t(lang, 'update.complete', { updated: applyResult.updated, created: applyResult.created }));
442
+ return 0;
443
+ }