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,102 @@
1
+ import { printUsageError, renderHelp } from '../lib/cli-output.js';
2
+ import { t } from '../lib/i18n.js';
3
+ import { resolveMustflowRoot } from '../lib/project-root.js';
4
+ import { inspectLineEndings } from '../../core/line-endings.js';
5
+ export function getLineEndingsHelp(lang = 'en') {
6
+ return renderHelp({
7
+ usage: 'mf line-endings <check|normalize> [options]',
8
+ summary: t(lang, 'lineEndings.help.summary'),
9
+ options: [
10
+ { label: '--json', description: t(lang, 'cli.option.json') },
11
+ { label: '--all', description: t(lang, 'lineEndings.help.option.all') },
12
+ { label: '--dry-run', description: t(lang, 'lineEndings.help.option.dryRun') },
13
+ { label: '--apply', description: t(lang, 'lineEndings.help.option.apply') },
14
+ { label: '-h, --help', description: t(lang, 'cli.option.help') },
15
+ ],
16
+ examples: [
17
+ 'mf line-endings check',
18
+ 'mf line-endings normalize --dry-run',
19
+ 'mf line-endings normalize --apply',
20
+ ],
21
+ exitCodes: [
22
+ { label: '0', description: t(lang, 'lineEndings.help.exit.ok') },
23
+ { label: '1', description: t(lang, 'lineEndings.help.exit.fail') },
24
+ ],
25
+ }, lang);
26
+ }
27
+ function parseLineEndingOptions(args, lang) {
28
+ const [action, ...rest] = args;
29
+ const json = rest.includes('--json');
30
+ const apply = rest.includes('--apply');
31
+ const dryRun = rest.includes('--dry-run');
32
+ const all = rest.includes('--all');
33
+ const supported = new Set(['--json', '--all', '--apply', '--dry-run']);
34
+ const unsupported = rest.find((arg) => arg.startsWith('-') && !supported.has(arg));
35
+ if (action !== 'check' && action !== 'normalize') {
36
+ return {
37
+ action: 'check',
38
+ json,
39
+ apply,
40
+ dryRun,
41
+ all,
42
+ error: action ? t(lang, 'lineEndings.error.unknownAction', { action }) : t(lang, 'lineEndings.error.missingAction'),
43
+ };
44
+ }
45
+ if (unsupported) {
46
+ return { action, json, apply, dryRun, all, error: t(lang, 'cli.error.unknownOption', { option: unsupported }) };
47
+ }
48
+ if (action === 'check' && (apply || dryRun)) {
49
+ return { action, json, apply, dryRun, all, error: t(lang, 'lineEndings.error.checkModeOption') };
50
+ }
51
+ if (action === 'normalize' && apply && dryRun) {
52
+ return { action, json, apply, dryRun, all, error: t(lang, 'lineEndings.error.conflictingModes') };
53
+ }
54
+ return { action, json, apply, dryRun, all };
55
+ }
56
+ function renderLineEndingSummary(report, lang) {
57
+ const lines = [
58
+ t(lang, 'lineEndings.title'),
59
+ `${t(lang, 'label.mode')}: ${report.mode}`,
60
+ `${t(lang, 'label.scope')}: ${report.scope}`,
61
+ `${t(lang, 'lineEndings.label.policy')}: ${report.policy}`,
62
+ `${t(lang, 'lineEndings.label.checkedFiles')}: ${report.checked_files}`,
63
+ `${t(lang, 'lineEndings.label.nonCompliantFiles')}: ${report.non_compliant_files.length}`,
64
+ `${t(lang, 'label.wroteFiles')}: ${report.wrote_files ? t(lang, 'value.yes') : t(lang, 'value.no')}`,
65
+ ];
66
+ if (report.issues.length > 0) {
67
+ lines.push(t(lang, 'lineEndings.label.issues'), ...report.issues.map((issue) => `- ${issue}`));
68
+ }
69
+ if (report.non_compliant_files.length > 0) {
70
+ lines.push(t(lang, 'lineEndings.label.files'));
71
+ for (const file of report.non_compliant_files) {
72
+ const action = file.changed ? t(lang, 'lineEndings.value.changed') : t(lang, 'lineEndings.value.wouldChange');
73
+ lines.push(`- ${file.path} [${file.lineEnding}] ${action}`);
74
+ }
75
+ }
76
+ if (report.non_compliant_files.length === 0 && report.issues.length === 0) {
77
+ lines.push(t(lang, 'lineEndings.clean'));
78
+ }
79
+ return lines.join('\n');
80
+ }
81
+ export function runLineEndings(args, reporter, lang = 'en') {
82
+ if (args.includes('--help') || args.includes('-h')) {
83
+ reporter.stdout(getLineEndingsHelp(lang));
84
+ return 0;
85
+ }
86
+ const options = parseLineEndingOptions(args, lang);
87
+ if (options.error) {
88
+ printUsageError(reporter, options.error, 'mf line-endings --help', getLineEndingsHelp(lang), lang);
89
+ return 1;
90
+ }
91
+ const mode = options.action === 'check' ? 'check' : 'normalize';
92
+ const report = inspectLineEndings(resolveMustflowRoot(), mode, {
93
+ apply: options.action === 'normalize' && options.apply,
94
+ scope: options.all ? 'tracked' : 'changed',
95
+ });
96
+ if (options.json) {
97
+ reporter.stdout(JSON.stringify(report, null, 2));
98
+ return report.ok ? 0 : 1;
99
+ }
100
+ reporter.stdout(renderLineEndingSummary(report, lang));
101
+ return report.ok ? 0 : 1;
102
+ }
@@ -0,0 +1,95 @@
1
+ import { printUsageError, renderHelp } from '../lib/cli-output.js';
2
+ import { t } from '../lib/i18n.js';
3
+ import { resolveMustflowRoot } from '../lib/project-root.js';
4
+ import { generateRepoMap, writeRepoMap } from '../lib/repo-map.js';
5
+ export function getMapHelp(lang = 'en') {
6
+ return renderHelp({
7
+ usage: 'mf map [options]',
8
+ summary: t(lang, 'map.help.summary'),
9
+ options: [
10
+ { label: '-h, --help', description: t(lang, 'cli.option.help') },
11
+ { label: '--stdout', description: t(lang, 'map.help.option.stdout') },
12
+ { label: '--write', description: t(lang, 'map.help.option.write') },
13
+ {
14
+ label: '--depth <level>',
15
+ description: t(lang, 'map.help.option.depth'),
16
+ },
17
+ {
18
+ label: '--include-nested',
19
+ description: t(lang, 'map.help.option.includeNested'),
20
+ },
21
+ {
22
+ label: '--root-only',
23
+ description: t(lang, 'map.help.option.rootOnly'),
24
+ },
25
+ ],
26
+ examples: ['mf map --stdout', 'mf map --write', 'mf map --write --include-nested'],
27
+ exitCodes: [
28
+ { label: '0', description: t(lang, 'map.help.exit.ok') },
29
+ { label: '1', description: t(lang, 'cli.common.invalidInput') },
30
+ ],
31
+ }, lang);
32
+ }
33
+ export function runMap(args, reporter, lang = 'en') {
34
+ if (args.includes('--help') || args.includes('-h')) {
35
+ reporter.stdout(getMapHelp(lang));
36
+ return 0;
37
+ }
38
+ let shouldPrint = false;
39
+ let shouldWrite = false;
40
+ let depth = 3;
41
+ let includeNested;
42
+ for (let index = 0; index < args.length; index += 1) {
43
+ const arg = args[index];
44
+ if (arg === '--stdout') {
45
+ shouldPrint = true;
46
+ continue;
47
+ }
48
+ if (arg === '--write') {
49
+ shouldWrite = true;
50
+ continue;
51
+ }
52
+ if (arg === '--include-nested') {
53
+ if (includeNested === false) {
54
+ printUsageError(reporter, t(lang, 'map.error.nestedConflict'), 'mf map --help', getMapHelp(lang), lang);
55
+ return 1;
56
+ }
57
+ includeNested = true;
58
+ continue;
59
+ }
60
+ if (arg === '--root-only') {
61
+ if (includeNested === true) {
62
+ printUsageError(reporter, t(lang, 'map.error.nestedConflict'), 'mf map --help', getMapHelp(lang), lang);
63
+ return 1;
64
+ }
65
+ includeNested = false;
66
+ continue;
67
+ }
68
+ if (arg === '--depth') {
69
+ const rawDepth = args[index + 1];
70
+ const parsedDepth = Number.parseInt(rawDepth ?? '', 10);
71
+ if (!Number.isInteger(parsedDepth) || parsedDepth < 1) {
72
+ printUsageError(reporter, t(lang, 'map.error.invalidDepth'), 'mf map --help', getMapHelp(lang), lang);
73
+ return 1;
74
+ }
75
+ depth = parsedDepth;
76
+ index += 1;
77
+ continue;
78
+ }
79
+ printUsageError(reporter, t(lang, 'cli.error.unknownOption', { option: arg }), 'mf map --help', getMapHelp(lang), lang);
80
+ return 1;
81
+ }
82
+ if (!shouldPrint && !shouldWrite) {
83
+ shouldPrint = true;
84
+ }
85
+ const projectRoot = resolveMustflowRoot();
86
+ const content = generateRepoMap(projectRoot, { depth, includeNested });
87
+ if (shouldWrite) {
88
+ writeRepoMap(projectRoot, content);
89
+ reporter.stdout(t(lang, 'map.wrote'));
90
+ }
91
+ if (shouldPrint) {
92
+ reporter.stdout(content);
93
+ }
94
+ return 0;
95
+ }
@@ -0,0 +1,442 @@
1
+ import { spawnSync } from 'node:child_process';
2
+ import path from 'node:path';
3
+ import { runCheck } from './check.js';
4
+ import { runClassify } from './classify.js';
5
+ import { runContext } from './context.js';
6
+ import { runDoctor } from './doctor.js';
7
+ import { runExplain } from './explain.js';
8
+ import { runHelp } from './help.js';
9
+ import { runImpact } from './impact.js';
10
+ import { runLineEndings } from './line-endings.js';
11
+ import { runMap } from './map.js';
12
+ import { runStatus } from './status.js';
13
+ import { runUpdate } from './update.js';
14
+ import { runVerify } from './verify.js';
15
+ import { runVersionSources } from './version-sources.js';
16
+ import { canRunMustflowBuiltinInProcess, isMustflowBinName } from '../../core/command-classification.js';
17
+ import { resolveSafeProjectCwd } from '../../core/command-cwd.js';
18
+ import { evaluateCommandIntentEligibility } from '../../core/command-intent-eligibility.js';
19
+ import { printUsageError, renderCliError, renderHelp } from '../lib/cli-output.js';
20
+ import { isRecord, readCommandContract, readMustflowConfigIfExists, readPositiveInteger, readString, readStringArray, } from '../../core/config-loading.js';
21
+ import { resolveRunReceiptRetentionPolicy } from '../../core/retention-policy.js';
22
+ import { t } from '../lib/i18n.js';
23
+ import { getPackageVersion } from '../lib/package-info.js';
24
+ import { resolveMustflowRoot } from '../lib/project-root.js';
25
+ import { createRunReceipt, writeRunReceipt } from '../../core/run-receipt.js';
26
+ function getSuccessExitCodes(intent) {
27
+ const value = intent.success_exit_codes;
28
+ if (!Array.isArray(value) || value.length === 0 || value.some((entry) => !Number.isInteger(entry))) {
29
+ return [0];
30
+ }
31
+ return value.map(Number);
32
+ }
33
+ function emitOutput(reporter, output, stream) {
34
+ if (!output) {
35
+ return;
36
+ }
37
+ const text = output.toString().trimEnd();
38
+ if (text.length === 0) {
39
+ return;
40
+ }
41
+ reporter[stream](text);
42
+ }
43
+ function terminateProcessTree(pid) {
44
+ if (!pid || pid <= 0) {
45
+ return;
46
+ }
47
+ if (process.platform === 'win32') {
48
+ spawnSync('taskkill', ['/PID', String(pid), '/T', '/F'], {
49
+ stdio: 'ignore',
50
+ windowsHide: true,
51
+ });
52
+ return;
53
+ }
54
+ try {
55
+ process.kill(-pid, 'SIGTERM');
56
+ }
57
+ catch {
58
+ try {
59
+ process.kill(pid, 'SIGTERM');
60
+ }
61
+ catch {
62
+ // The child may already be gone after Node's spawn timeout handling.
63
+ }
64
+ }
65
+ }
66
+ function getKillMethod() {
67
+ return process.platform === 'win32' ? 'taskkill_process_tree' : 'process_group_sigterm';
68
+ }
69
+ function getPathEnvKey(env) {
70
+ return Object.keys(env).find((key) => key.toLowerCase() === 'path') ?? 'PATH';
71
+ }
72
+ function sameResolvedPath(left, right) {
73
+ const resolvedLeft = path.resolve(left);
74
+ const resolvedRight = path.resolve(right);
75
+ return process.platform === 'win32'
76
+ ? resolvedLeft.toLowerCase() === resolvedRight.toLowerCase()
77
+ : resolvedLeft === resolvedRight;
78
+ }
79
+ function createCommandEnv(projectRoot) {
80
+ const env = { ...process.env };
81
+ const pathKey = getPathEnvKey(env);
82
+ const localBinPath = path.join(projectRoot, 'node_modules', '.bin');
83
+ const currentPath = env[pathKey];
84
+ if (currentPath) {
85
+ env[pathKey] = currentPath
86
+ .split(path.delimiter)
87
+ .filter((entry) => entry.length > 0 && !sameResolvedPath(entry, localBinPath))
88
+ .join(path.delimiter);
89
+ }
90
+ return env;
91
+ }
92
+ function shouldUseShellForArgvExecutable(executablePath) {
93
+ return process.platform === 'win32' && executablePath.toLowerCase().endsWith('.cmd');
94
+ }
95
+ function isMustflowBuiltinIntent(intent) {
96
+ return readString(intent, 'kind') === 'mustflow_builtin';
97
+ }
98
+ function resolveCurrentCliEntrypoint() {
99
+ const entrypoint = process.argv[1];
100
+ return entrypoint ? path.resolve(entrypoint) : undefined;
101
+ }
102
+ function resolveArgvCommand(intent, commandArgv) {
103
+ const [command = '', ...args] = commandArgv;
104
+ if (isMustflowBuiltinIntent(intent) && isMustflowBinName(command)) {
105
+ const entrypoint = resolveCurrentCliEntrypoint();
106
+ if (entrypoint) {
107
+ return {
108
+ executable: process.execPath,
109
+ args: [entrypoint, ...args],
110
+ shell: false,
111
+ };
112
+ }
113
+ }
114
+ return {
115
+ executable: command,
116
+ args,
117
+ shell: shouldUseShellForArgvExecutable(command),
118
+ };
119
+ }
120
+ function createBufferedReporter() {
121
+ const stdout = [];
122
+ const stderr = [];
123
+ return {
124
+ reporter: {
125
+ stdout(message) {
126
+ stdout.push(`${message}\n`);
127
+ },
128
+ stderr(message) {
129
+ stderr.push(`${message}\n`);
130
+ },
131
+ },
132
+ stdout() {
133
+ return stdout.join('');
134
+ },
135
+ stderr() {
136
+ return stderr.join('');
137
+ },
138
+ };
139
+ }
140
+ /**
141
+ * mf:anchor cli.run.builtin-inprocess
142
+ * purpose: Dispatch selected mustflow built-in commands without spawning a nested CLI process.
143
+ * search: builtin intent, in-process command, nested mf run, run receipt
144
+ * invariant: Only commands classified by command-classification can use this path.
145
+ * risk: config, state
146
+ */
147
+ function runKnownBuiltinCommand(args, reporter, lang) {
148
+ const [command, ...commandArgs] = args;
149
+ if ((command === '--version' || command === '-v' || command === 'version') && commandArgs.length === 0) {
150
+ reporter.stdout(getPackageVersion());
151
+ return 0;
152
+ }
153
+ if (!canRunMustflowBuiltinInProcess(command)) {
154
+ return undefined;
155
+ }
156
+ if (command === 'check') {
157
+ return runCheck(commandArgs, reporter, lang);
158
+ }
159
+ if (command === 'classify') {
160
+ return runClassify(commandArgs, reporter, lang);
161
+ }
162
+ if (command === 'context') {
163
+ return runContext(commandArgs, reporter, lang);
164
+ }
165
+ if (command === 'doctor') {
166
+ return runDoctor(commandArgs, reporter, lang);
167
+ }
168
+ if (command === 'explain') {
169
+ return runExplain(commandArgs, reporter, lang);
170
+ }
171
+ if (command === 'help') {
172
+ return runHelp(commandArgs, reporter, lang);
173
+ }
174
+ if (command === 'impact') {
175
+ return runImpact(commandArgs, reporter, lang);
176
+ }
177
+ if (command === 'line-endings') {
178
+ return runLineEndings(commandArgs, reporter, lang);
179
+ }
180
+ if (command === 'map') {
181
+ return runMap(commandArgs, reporter, lang);
182
+ }
183
+ if (command === 'status') {
184
+ return runStatus(commandArgs, reporter, lang);
185
+ }
186
+ if (command === 'update') {
187
+ return runUpdate(commandArgs, reporter, lang);
188
+ }
189
+ if (command === 'version-sources') {
190
+ return runVersionSources(commandArgs, reporter, lang);
191
+ }
192
+ if (command === 'verify') {
193
+ return runVerify(commandArgs, reporter, lang);
194
+ }
195
+ return undefined;
196
+ }
197
+ function withWorkingDirectory(cwd, callback) {
198
+ const previousCwd = process.cwd();
199
+ process.chdir(cwd);
200
+ try {
201
+ return callback();
202
+ }
203
+ finally {
204
+ process.chdir(previousCwd);
205
+ }
206
+ }
207
+ function runBuiltinArgvInProcess(commandArgv, cwd, lang) {
208
+ const [command = '', ...builtinArgs] = commandArgv;
209
+ if (!isMustflowBinName(command)) {
210
+ return undefined;
211
+ }
212
+ const output = createBufferedReporter();
213
+ try {
214
+ const status = withWorkingDirectory(cwd, () => runKnownBuiltinCommand(builtinArgs, output.reporter, lang));
215
+ if (status === undefined) {
216
+ return undefined;
217
+ }
218
+ return {
219
+ status,
220
+ signal: null,
221
+ stdout: output.stdout(),
222
+ stderr: output.stderr(),
223
+ };
224
+ }
225
+ catch (error) {
226
+ const message = error instanceof Error ? error.message : String(error);
227
+ return {
228
+ status: 1,
229
+ signal: null,
230
+ stdout: output.stdout(),
231
+ stderr: `${output.stderr()}${message}\n`,
232
+ };
233
+ }
234
+ }
235
+ function runArgvCommand(command, cwd, maxOutputBytes, env, timeoutSeconds) {
236
+ return spawnSync(command?.executable ?? '', command?.args ?? [], {
237
+ cwd,
238
+ encoding: 'utf8',
239
+ input: '',
240
+ maxBuffer: maxOutputBytes,
241
+ env,
242
+ shell: command?.shell ?? false,
243
+ stdio: ['ignore', 'pipe', 'pipe'],
244
+ timeout: timeoutSeconds * 1000,
245
+ windowsHide: true,
246
+ });
247
+ }
248
+ function runShellCommand(command, cwd, maxOutputBytes, env, timeoutSeconds) {
249
+ return spawnSync(command ?? '', {
250
+ cwd,
251
+ encoding: 'utf8',
252
+ input: '',
253
+ maxBuffer: maxOutputBytes,
254
+ env,
255
+ shell: true,
256
+ stdio: ['ignore', 'pipe', 'pipe'],
257
+ timeout: timeoutSeconds * 1000,
258
+ windowsHide: true,
259
+ });
260
+ }
261
+ function getRunStatus(error, exitCode, successExitCodes) {
262
+ const errorWithCode = error;
263
+ if (errorWithCode?.code === 'ETIMEDOUT') {
264
+ return 'timed_out';
265
+ }
266
+ if (error) {
267
+ return 'start_failed';
268
+ }
269
+ return exitCode !== null && successExitCodes.includes(exitCode) ? 'passed' : 'failed';
270
+ }
271
+ export function getRunHelp(lang = 'en') {
272
+ return renderHelp({
273
+ usage: 'mf run <intent> [options]',
274
+ summary: t(lang, 'run.help.summary'),
275
+ options: [
276
+ { label: '--json', description: t(lang, 'run.help.option.json') },
277
+ { label: '-h, --help', description: t(lang, 'cli.option.help') },
278
+ ],
279
+ examples: ['mf run test', 'mf run lint --json', 'mf run mustflow_check'],
280
+ exitCodes: [
281
+ {
282
+ label: '0',
283
+ description: t(lang, 'run.help.exit.ok'),
284
+ },
285
+ {
286
+ label: '1',
287
+ description: t(lang, 'run.help.exit.fail'),
288
+ },
289
+ ],
290
+ }, lang);
291
+ }
292
+ /**
293
+ * mf:anchor cli.run.intent-contract
294
+ * purpose: Enforce command intent eligibility before executing a configured oneshot command.
295
+ * search: command contract, agent_allowed, oneshot, stdin closed, timeout
296
+ * invariant: Execution requires configured status, oneshot lifecycle, agent_allowed policy, and closed stdin.
297
+ * risk: config, security, state
298
+ */
299
+ export function runRun(args, reporter, lang = 'en') {
300
+ if (args.includes('--help') || args.includes('-h')) {
301
+ reporter.stdout(getRunHelp(lang));
302
+ return 0;
303
+ }
304
+ const supportedOptions = new Set(['--json']);
305
+ const unsupported = args.filter((arg) => arg.startsWith('-') && !supportedOptions.has(arg));
306
+ if (unsupported.length > 0) {
307
+ printUsageError(reporter, t(lang, 'cli.error.unknownOption', { option: unsupported[0] }), 'mf run --help', getRunHelp(lang), lang);
308
+ return 1;
309
+ }
310
+ const json = args.includes('--json');
311
+ const positional = args.filter((arg) => !supportedOptions.has(arg));
312
+ const [intentName, ...extra] = positional;
313
+ if (!intentName) {
314
+ printUsageError(reporter, t(lang, 'run.error.missingIntent'), 'mf run --help', getRunHelp(lang), lang);
315
+ return 1;
316
+ }
317
+ if (extra.length > 0) {
318
+ printUsageError(reporter, t(lang, 'cli.error.unexpectedArgument', { argument: extra[0] }), 'mf run --help', getRunHelp(lang), lang);
319
+ return 1;
320
+ }
321
+ const projectRoot = resolveMustflowRoot();
322
+ const contract = readCommandContract(projectRoot);
323
+ const runReceiptPolicy = resolveRunReceiptRetentionPolicy(readMustflowConfigIfExists(projectRoot));
324
+ const intent = contract.intents[intentName];
325
+ if (!isRecord(intent)) {
326
+ reporter.stderr(renderCliError(t(lang, 'run.error.unknownIntent', { intent: intentName }), 'mf help commands', lang));
327
+ return 1;
328
+ }
329
+ const eligibility = evaluateCommandIntentEligibility(intentName, intent);
330
+ const intentStatus = readString(intent, 'status') ?? 'unknown';
331
+ const lifecycle = readString(intent, 'lifecycle');
332
+ const runPolicy = readString(intent, 'run_policy');
333
+ const timeoutSeconds = readPositiveInteger(intent, 'timeout_seconds');
334
+ if (!eligibility.ok) {
335
+ if (eligibility.code === 'status_not_configured') {
336
+ reporter.stderr(renderCliError(t(lang, 'run.error.statusNotConfigured', { intent: intentName, status: intentStatus }), 'mf help commands', lang));
337
+ return 1;
338
+ }
339
+ if (eligibility.code === 'lifecycle_not_oneshot') {
340
+ reporter.stderr(renderCliError(t(lang, 'run.error.lifecycleNotOneshot', { intent: intentName, lifecycle: lifecycle ?? 'unknown' }), 'mf help commands', lang));
341
+ return 1;
342
+ }
343
+ if (eligibility.code === 'run_policy_not_agent_allowed') {
344
+ reporter.stderr(renderCliError(t(lang, 'run.error.runPolicy', { intent: intentName }), 'mf help commands', lang));
345
+ return 1;
346
+ }
347
+ if (eligibility.code === 'stdin_not_closed') {
348
+ reporter.stderr(renderCliError(t(lang, 'run.error.stdin', { intent: intentName }), 'mf help commands', lang));
349
+ return 1;
350
+ }
351
+ if (eligibility.code === 'missing_timeout') {
352
+ reporter.stderr(renderCliError(t(lang, 'run.error.timeout', { intent: intentName }), 'mf help commands', lang));
353
+ return 1;
354
+ }
355
+ if (eligibility.code === 'missing_command_source') {
356
+ reporter.stderr(renderCliError(t(lang, 'run.error.commandSource', { intent: intentName }), 'mf help commands', lang));
357
+ return 1;
358
+ }
359
+ if (eligibility.code === 'unsafe_intent_name') {
360
+ reporter.stderr(renderCliError(`Intent ${intentName} has an unsafe name. ${eligibility.detail ?? 'Use a shell-safe intent name.'}`, 'mf help commands', lang));
361
+ return 1;
362
+ }
363
+ if (eligibility.code === 'blocked_shell_background_pattern') {
364
+ reporter.stderr(renderCliError(`Intent ${intentName} is blocked. ${eligibility.detail ?? 'Shell commands must not spawn background work.'}`, 'mf help commands', lang));
365
+ return 1;
366
+ }
367
+ reporter.stderr(renderCliError(t(lang, 'run.error.unknownIntent', { intent: intentName }), 'mf help commands', lang));
368
+ return 1;
369
+ }
370
+ const maxOutputBytes = readPositiveInteger(intent, 'max_output_bytes') ?? readPositiveInteger(contract.defaults, 'max_output_bytes') ?? 1_048_576;
371
+ if (!timeoutSeconds) {
372
+ reporter.stderr(renderCliError(t(lang, 'run.error.timeout', { intent: intentName }), 'mf help commands', lang));
373
+ return 1;
374
+ }
375
+ const cwd = resolveSafeProjectCwd(projectRoot, readString(intent, 'cwd') ?? readString(contract.defaults, 'default_cwd'));
376
+ const successExitCodes = getSuccessExitCodes(intent);
377
+ const argv = readStringArray(intent, 'argv');
378
+ const commandArgv = argv && argv.length > 0 ? argv : undefined;
379
+ const shellCommand = intent.mode === 'shell' ? readString(intent, 'cmd') : undefined;
380
+ const env = createCommandEnv(projectRoot);
381
+ const lifecycleValue = lifecycle ?? 'oneshot';
382
+ const runPolicyValue = runPolicy ?? 'agent_allowed';
383
+ const mode = commandArgv ? 'argv' : 'shell';
384
+ const startedAt = new Date();
385
+ const argvCommand = commandArgv ? resolveArgvCommand(intent, commandArgv) : undefined;
386
+ const result = commandArgv && isMustflowBuiltinIntent(intent)
387
+ ? (runBuiltinArgvInProcess(commandArgv, cwd, lang) ??
388
+ runArgvCommand(argvCommand, cwd, maxOutputBytes, env, timeoutSeconds))
389
+ : commandArgv
390
+ ? runArgvCommand(argvCommand, cwd, maxOutputBytes, env, timeoutSeconds)
391
+ : runShellCommand(shellCommand, cwd, maxOutputBytes, env, timeoutSeconds);
392
+ const finishedAt = new Date();
393
+ const exitCode = typeof result.status === 'number' ? result.status : null;
394
+ const runStatus = getRunStatus(result.error, exitCode, successExitCodes);
395
+ let killMethod = null;
396
+ if (runStatus === 'timed_out') {
397
+ killMethod = getKillMethod();
398
+ terminateProcessTree(result.pid);
399
+ }
400
+ const receipt = createRunReceipt({
401
+ intent: intentName,
402
+ status: runStatus,
403
+ timedOut: runStatus === 'timed_out',
404
+ startedAt,
405
+ finishedAt,
406
+ projectRoot,
407
+ cwd,
408
+ lifecycle: lifecycleValue,
409
+ runPolicy: runPolicyValue,
410
+ mode,
411
+ argv: commandArgv,
412
+ cmd: shellCommand,
413
+ timeoutSeconds,
414
+ maxOutputBytes,
415
+ successExitCodes,
416
+ exitCode,
417
+ signal: result.signal,
418
+ error: result.error?.message ?? null,
419
+ killMethod,
420
+ stdout: result.stdout,
421
+ stderr: result.stderr,
422
+ stdoutTailBytes: runReceiptPolicy.stdoutTailBytes,
423
+ stderrTailBytes: runReceiptPolicy.stderrTailBytes,
424
+ });
425
+ writeRunReceipt(projectRoot, receipt);
426
+ if (json) {
427
+ reporter.stdout(JSON.stringify(receipt, null, 2));
428
+ return runStatus === 'passed' ? 0 : 1;
429
+ }
430
+ emitOutput(reporter, result.stdout, 'stdout');
431
+ emitOutput(reporter, result.stderr, 'stderr');
432
+ if (result.error) {
433
+ const errorWithCode = result.error;
434
+ if (errorWithCode.code === 'ETIMEDOUT') {
435
+ reporter.stderr(t(lang, 'run.error.timedOut', { intent: intentName, seconds: timeoutSeconds }));
436
+ return 1;
437
+ }
438
+ reporter.stderr(t(lang, 'run.error.startFailed', { intent: intentName, message: result.error.message }));
439
+ return 1;
440
+ }
441
+ return runStatus === 'passed' ? 0 : 1;
442
+ }