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,218 @@
1
+ #!/usr/bin/env node
2
+ import { realpathSync } from 'node:fs';
3
+ import path from 'node:path';
4
+ import { fileURLToPath } from 'node:url';
5
+ import { runCheck } from './commands/check.js';
6
+ import { runClassify } from './commands/classify.js';
7
+ import { runContractLint } from './commands/contract-lint.js';
8
+ import { runContext } from './commands/context.js';
9
+ import { runDashboard } from './commands/dashboard.js';
10
+ import { runDoctor } from './commands/doctor.js';
11
+ import { runDocs } from './commands/docs.js';
12
+ import { runExplain } from './commands/explain.js';
13
+ import { runHelp } from './commands/help.js';
14
+ import { runImpact } from './commands/impact.js';
15
+ import { runInit } from './commands/init.js';
16
+ import { runIndex } from './commands/index.js';
17
+ import { runLineEndings } from './commands/line-endings.js';
18
+ import { runMap } from './commands/map.js';
19
+ import { runRun } from './commands/run.js';
20
+ import { runSearch } from './commands/search.js';
21
+ import { runStatus } from './commands/status.js';
22
+ import { runUpdate } from './commands/update.js';
23
+ import { runVerify } from './commands/verify.js';
24
+ import { runVersion } from './commands/version.js';
25
+ import { runVersionSources } from './commands/version-sources.js';
26
+ import { COMMAND_DEFINITIONS } from './lib/command-registry.js';
27
+ import { renderCliError, renderHelp } from './lib/cli-output.js';
28
+ import { DEFAULT_CLI_LANG, SUPPORTED_CLI_LANGS, isCliLang, t } from './lib/i18n.js';
29
+ import { consoleReporter } from './lib/reporter.js';
30
+ function getTopLevelHelp(lang) {
31
+ return renderHelp({
32
+ usage: 'mf [--lang <lang>] <command> [options]',
33
+ commands: COMMAND_DEFINITIONS.map((command) => ({
34
+ label: command.usage,
35
+ description: t(lang, command.summaryKey),
36
+ })),
37
+ options: [
38
+ {
39
+ label: '--lang <lang>',
40
+ description: t(lang, 'top.help.option.lang', { languages: SUPPORTED_CLI_LANGS.join(', ') }),
41
+ },
42
+ { label: '-h, --help', description: t(lang, 'cli.option.help') },
43
+ { label: '-v, --version', description: t(lang, 'top.help.option.version') },
44
+ ],
45
+ examples: [
46
+ 'mf --lang ko help',
47
+ 'mf init --dry-run',
48
+ 'mf doctor --json',
49
+ 'mf docs review list',
50
+ 'mf check --json',
51
+ 'mf classify --changed',
52
+ 'mf contract-lint --json',
53
+ 'mf context --json',
54
+ 'mf map --write',
55
+ 'mf search mustflow_check',
56
+ 'mf explain authority AGENTS.md',
57
+ 'mf impact --changed',
58
+ 'mf verify --reason code_change',
59
+ 'mf line-endings check',
60
+ 'mf version --check',
61
+ 'mf version-sources --json',
62
+ ],
63
+ exitCodes: [
64
+ {
65
+ label: '0',
66
+ description: t(lang, 'top.help.exit.ok'),
67
+ },
68
+ {
69
+ label: '1',
70
+ description: t(lang, 'top.help.exit.fail'),
71
+ },
72
+ ],
73
+ }, lang);
74
+ }
75
+ function getErrorMessage(error) {
76
+ return error instanceof Error ? error.message : String(error);
77
+ }
78
+ function parseGlobalOptions(argv) {
79
+ let lang = DEFAULT_CLI_LANG;
80
+ const args = [];
81
+ for (let index = 0; index < argv.length; index += 1) {
82
+ const arg = argv[index];
83
+ if (!arg) {
84
+ continue;
85
+ }
86
+ if (arg === '--lang') {
87
+ const value = argv[index + 1];
88
+ if (!value || value.startsWith('-')) {
89
+ return { lang, args, error: t(lang, 'cli.error.missingLangValue') };
90
+ }
91
+ if (!isCliLang(value)) {
92
+ return { lang, args, error: t(lang, 'cli.error.unsupportedLanguage', { language: value }) };
93
+ }
94
+ lang = value;
95
+ index += 1;
96
+ continue;
97
+ }
98
+ if (arg.startsWith('--lang=')) {
99
+ const value = arg.slice('--lang='.length);
100
+ if (!isCliLang(value)) {
101
+ return { lang, args, error: t(lang, 'cli.error.unsupportedLanguage', { language: value }) };
102
+ }
103
+ lang = value;
104
+ continue;
105
+ }
106
+ args.push(arg);
107
+ }
108
+ return { lang, args };
109
+ }
110
+ export async function runCli(argv, reporter = consoleReporter) {
111
+ const parsed = parseGlobalOptions(argv);
112
+ const [command, ...args] = parsed.args;
113
+ if (parsed.error) {
114
+ reporter.stderr(renderCliError(parsed.error, 'mf --help', parsed.lang));
115
+ reporter.stdout(getTopLevelHelp(parsed.lang));
116
+ return 1;
117
+ }
118
+ if (!command || command === '--help' || command === '-h') {
119
+ reporter.stdout(getTopLevelHelp(parsed.lang));
120
+ return 0;
121
+ }
122
+ if (command === '--version' || command === '-v' || command === 'version') {
123
+ return runVersion(args, reporter, parsed.lang);
124
+ }
125
+ if (command === 'init') {
126
+ return runInit(args, reporter, parsed.lang);
127
+ }
128
+ if (command === 'check') {
129
+ return runCheck(args, reporter, parsed.lang);
130
+ }
131
+ if (command === 'classify') {
132
+ return runClassify(args, reporter, parsed.lang);
133
+ }
134
+ if (command === 'contract-lint') {
135
+ return runContractLint(args, reporter, parsed.lang);
136
+ }
137
+ if (command === 'status') {
138
+ return runStatus(args, reporter, parsed.lang);
139
+ }
140
+ if (command === 'update') {
141
+ return runUpdate(args, reporter, parsed.lang);
142
+ }
143
+ if (command === 'map') {
144
+ return runMap(args, reporter, parsed.lang);
145
+ }
146
+ if (command === 'line-endings') {
147
+ return runLineEndings(args, reporter, parsed.lang);
148
+ }
149
+ if (command === 'run') {
150
+ return runRun(args, reporter, parsed.lang);
151
+ }
152
+ if (command === 'context') {
153
+ return runContext(args, reporter, parsed.lang);
154
+ }
155
+ if (command === 'doctor') {
156
+ return runDoctor(args, reporter, parsed.lang);
157
+ }
158
+ if (command === 'docs') {
159
+ return runDocs(args, reporter, parsed.lang);
160
+ }
161
+ if (command === 'index') {
162
+ return runIndex(args, reporter, parsed.lang);
163
+ }
164
+ if (command === 'search') {
165
+ return runSearch(args, reporter, parsed.lang);
166
+ }
167
+ if (command === 'dashboard') {
168
+ return runDashboard(args, reporter, parsed.lang);
169
+ }
170
+ if (command === 'version-sources') {
171
+ return runVersionSources(args, reporter, parsed.lang);
172
+ }
173
+ if (command === 'verify') {
174
+ return runVerify(args, reporter, parsed.lang);
175
+ }
176
+ if (command === 'explain') {
177
+ return runExplain(args, reporter, parsed.lang);
178
+ }
179
+ if (command === 'impact') {
180
+ return runImpact(args, reporter, parsed.lang);
181
+ }
182
+ if (command === 'help') {
183
+ return runHelp(args, reporter, parsed.lang);
184
+ }
185
+ reporter.stderr(renderCliError(t(parsed.lang, 'cli.error.unknownCommand', { command }), 'mf --help', parsed.lang));
186
+ reporter.stdout(getTopLevelHelp(parsed.lang));
187
+ return 1;
188
+ }
189
+ function isDirectRun() {
190
+ const entrypoint = process.argv[1];
191
+ if (!entrypoint) {
192
+ return false;
193
+ }
194
+ const currentFile = fileURLToPath(import.meta.url);
195
+ const resolvedEntrypoint = path.resolve(entrypoint);
196
+ const resolvedCurrentFile = path.resolve(currentFile);
197
+ if (resolvedEntrypoint === resolvedCurrentFile) {
198
+ return true;
199
+ }
200
+ try {
201
+ return realpathSync.native(resolvedEntrypoint) === realpathSync.native(resolvedCurrentFile);
202
+ }
203
+ catch {
204
+ return false;
205
+ }
206
+ }
207
+ async function main() {
208
+ try {
209
+ process.exitCode = await runCli(process.argv.slice(2));
210
+ }
211
+ catch (error) {
212
+ consoleReporter.stderr(renderCliError(getErrorMessage(error), 'mf --help'));
213
+ process.exitCode = 1;
214
+ }
215
+ }
216
+ if (isDirectRun()) {
217
+ void main();
218
+ }
@@ -0,0 +1,342 @@
1
+ import { existsSync, readFileSync } from 'node:fs';
2
+ import { createHash } from 'node:crypto';
3
+ import path from 'node:path';
4
+ import { isRecord, readPositiveInteger, readString, readStringArray, } from './command-contract.js';
5
+ import { readRetentionStore } from '../../core/retention-policy.js';
6
+ import { toPosixPath } from './filesystem.js';
7
+ import { inspectManifestLock } from './manifest-lock.js';
8
+ import { readTomlFile } from './toml.js';
9
+ const CONTEXT_SCHEMA_VERSION = '1';
10
+ const COMMANDS_RELATIVE_PATH = '.mustflow/config/commands.toml';
11
+ const MUSTFLOW_RELATIVE_PATH = '.mustflow/config/mustflow.toml';
12
+ const PREFERENCES_RELATIVE_PATH = '.mustflow/config/preferences.toml';
13
+ const LATEST_RUN_RELATIVE_PATH = '.mustflow/state/runs/latest.json';
14
+ const CACHE_RELATIVE_PATH = '.mustflow/cache/';
15
+ const STATE_RELATIVE_PATH = '.mustflow/state/';
16
+ const DEFAULT_PROMPT_CACHE_STABLE_READ = [
17
+ 'AGENTS.md',
18
+ '.mustflow/docs/agent-workflow.md',
19
+ '.mustflow/config/mustflow.toml',
20
+ '.mustflow/config/commands.toml',
21
+ '.mustflow/skills/INDEX.md',
22
+ ];
23
+ const DEFAULT_PROMPT_CACHE_TASK_SOURCES = [
24
+ '.mustflow/context/INDEX.md',
25
+ 'REPO_MAP.md',
26
+ 'matching_skill',
27
+ 'relevant_source_files',
28
+ ];
29
+ const DEFAULT_PROMPT_CACHE_VOLATILE_SOURCES = [
30
+ '.mustflow/state/runs/latest.json',
31
+ 'changed_files',
32
+ 'command_output_tail',
33
+ 'current_user_task',
34
+ ];
35
+ const BLOCKED_ACTIONS = [
36
+ 'unconfigured_project_command',
37
+ 'unmanaged_long_running_process',
38
+ 'auto_push',
39
+ 'raw_transcript_storage',
40
+ ];
41
+ function safeExists(projectRoot, relativePath) {
42
+ const resolved = path.resolve(projectRoot, ...relativePath.split('/'));
43
+ const root = path.resolve(projectRoot);
44
+ const relative = path.relative(root, resolved);
45
+ if (relative.startsWith('..') || path.isAbsolute(relative)) {
46
+ return false;
47
+ }
48
+ return existsSync(resolved);
49
+ }
50
+ function safeRead(projectRoot, relativePath) {
51
+ const resolved = path.resolve(projectRoot, ...relativePath.split('/'));
52
+ const root = path.resolve(projectRoot);
53
+ const relative = path.relative(root, resolved);
54
+ if (relative.startsWith('..') || path.isAbsolute(relative) || !existsSync(resolved)) {
55
+ return null;
56
+ }
57
+ return readFileSync(resolved, 'utf8');
58
+ }
59
+ function readTomlTableIfExists(projectRoot, relativePath) {
60
+ const filePath = path.join(projectRoot, ...relativePath.split('/'));
61
+ if (!existsSync(filePath)) {
62
+ return undefined;
63
+ }
64
+ const parsed = readTomlFile(filePath);
65
+ return isRecord(parsed) ? parsed : undefined;
66
+ }
67
+ function readNestedTable(table, key) {
68
+ if (!table || !isRecord(table[key])) {
69
+ return undefined;
70
+ }
71
+ return table[key];
72
+ }
73
+ function readBoolean(table, key, fallback) {
74
+ const value = table?.[key];
75
+ return typeof value === 'boolean' ? value : fallback;
76
+ }
77
+ function readOptionalString(table, key) {
78
+ return table ? readString(table, key) ?? null : null;
79
+ }
80
+ function readOptionalStringArray(table, key) {
81
+ return table ? readStringArray(table, key) ?? null : null;
82
+ }
83
+ function readNumber(table, key) {
84
+ const value = table?.[key];
85
+ return typeof value === 'number' && Number.isFinite(value) ? value : null;
86
+ }
87
+ function readPathContext(projectRoot, paths) {
88
+ return paths.map((relativePath) => ({
89
+ path: toPosixPath(relativePath),
90
+ exists: safeExists(projectRoot, relativePath),
91
+ }));
92
+ }
93
+ function readScalarObject(table) {
94
+ if (!table) {
95
+ return {};
96
+ }
97
+ const result = {};
98
+ for (const [key, value] of Object.entries(table)) {
99
+ if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean' || value === null) {
100
+ result[key] = value;
101
+ continue;
102
+ }
103
+ if (Array.isArray(value) && value.every((entry) => typeof entry === 'string')) {
104
+ result[key] = value;
105
+ }
106
+ }
107
+ return result;
108
+ }
109
+ function sha256(content) {
110
+ return `sha256:${createHash('sha256').update(content).digest('hex')}`;
111
+ }
112
+ function isRunnableIntent(intent) {
113
+ return (readString(intent, 'status') === 'configured' &&
114
+ readString(intent, 'lifecycle') === 'oneshot' &&
115
+ readString(intent, 'run_policy') === 'agent_allowed' &&
116
+ intent.stdin === 'closed' &&
117
+ Boolean(readPositiveInteger(intent, 'timeout_seconds')));
118
+ }
119
+ function readCommandContractContext(projectRoot) {
120
+ const commands = readTomlTableIfExists(projectRoot, COMMANDS_RELATIVE_PATH);
121
+ if (!commands || !isRecord(commands.intents)) {
122
+ return {
123
+ path: COMMANDS_RELATIVE_PATH,
124
+ exists: safeExists(projectRoot, COMMANDS_RELATIVE_PATH),
125
+ intents: [],
126
+ runnable_intents: [],
127
+ };
128
+ }
129
+ const intents = [];
130
+ const runnableIntents = [];
131
+ for (const [name, intent] of Object.entries(commands.intents).sort(([left], [right]) => left.localeCompare(right))) {
132
+ if (!isRecord(intent)) {
133
+ continue;
134
+ }
135
+ const status = readString(intent, 'status') ?? 'unknown';
136
+ const lifecycle = readString(intent, 'lifecycle') ?? null;
137
+ const runPolicy = readString(intent, 'run_policy') ?? null;
138
+ intents.push({
139
+ name,
140
+ status,
141
+ lifecycle,
142
+ run_policy: runPolicy,
143
+ description: readString(intent, 'description') ?? null,
144
+ });
145
+ if (isRunnableIntent(intent)) {
146
+ runnableIntents.push(name);
147
+ }
148
+ }
149
+ return {
150
+ path: COMMANDS_RELATIVE_PATH,
151
+ exists: true,
152
+ intents,
153
+ runnable_intents: runnableIntents,
154
+ };
155
+ }
156
+ function readEffectivePolicyContext(mustflow, preferences) {
157
+ const verification = readNestedTable(mustflow, 'verification');
158
+ const retention = readNestedTable(mustflow, 'retention');
159
+ const git = readNestedTable(preferences, 'git');
160
+ const allowInferredCommands = readBoolean(verification, 'allow_inferred_commands', false);
161
+ const requireConfiguredIntents = readBoolean(verification, 'require_configured_intents', true);
162
+ const rawEventsStore = readRetentionStore(retention, 'raw_events') ?? 'none';
163
+ return {
164
+ entrypoint: 'AGENTS.md',
165
+ nearest_agents: 'AGENTS.md',
166
+ command_contract: COMMANDS_RELATIVE_PATH,
167
+ project_commands_require_mf_run: requireConfiguredIntents && !allowInferredCommands,
168
+ allow_inferred_commands: allowInferredCommands,
169
+ auto_stage: readBoolean(git, 'auto_stage', false),
170
+ auto_commit: readBoolean(git, 'auto_commit', false),
171
+ auto_push: readBoolean(git, 'auto_push', false),
172
+ state_is_versioned: false,
173
+ raw_logs_allowed: rawEventsStore !== 'none',
174
+ };
175
+ }
176
+ function readStatePolicyContext() {
177
+ return {
178
+ cache_path: CACHE_RELATIVE_PATH,
179
+ state_path: STATE_RELATIVE_PATH,
180
+ versioned: false,
181
+ safe_to_delete: true,
182
+ stores_raw_conversation: false,
183
+ stores_full_terminal_output: false,
184
+ stores_hidden_chain_of_thought: false,
185
+ };
186
+ }
187
+ function readLatestRunContext(projectRoot) {
188
+ const latestPath = path.join(projectRoot, ...LATEST_RUN_RELATIVE_PATH.split('/'));
189
+ if (!existsSync(latestPath)) {
190
+ return {
191
+ path: LATEST_RUN_RELATIVE_PATH,
192
+ exists: false,
193
+ };
194
+ }
195
+ try {
196
+ const parsed = JSON.parse(readFileSync(latestPath, 'utf8'));
197
+ if (!isRecord(parsed)) {
198
+ throw new Error('latest run receipt must contain a JSON object');
199
+ }
200
+ return {
201
+ path: LATEST_RUN_RELATIVE_PATH,
202
+ exists: true,
203
+ valid: true,
204
+ intent: typeof parsed.intent === 'string' ? parsed.intent : 'unknown',
205
+ status: typeof parsed.status === 'string' ? parsed.status : 'unknown',
206
+ timed_out: parsed.timed_out === true,
207
+ exit_code: typeof parsed.exit_code === 'number' ? parsed.exit_code : null,
208
+ finished_at: typeof parsed.finished_at === 'string' ? parsed.finished_at : null,
209
+ duration_ms: typeof parsed.duration_ms === 'number' ? parsed.duration_ms : null,
210
+ };
211
+ }
212
+ catch (error) {
213
+ return {
214
+ path: LATEST_RUN_RELATIVE_PATH,
215
+ exists: true,
216
+ valid: false,
217
+ error: error instanceof Error ? error.message : String(error),
218
+ };
219
+ }
220
+ }
221
+ function readPromptCacheSettings(mustflow) {
222
+ const promptCache = readNestedTable(mustflow, 'prompt_cache');
223
+ return {
224
+ enabled: readBoolean(promptCache, 'enabled', false),
225
+ strategy: readOptionalString(promptCache, 'strategy'),
226
+ stable_prefix_policy: readOptionalString(promptCache, 'stable_prefix_policy'),
227
+ prefer_references_when_unchanged: readBoolean(promptCache, 'prefer_references_when_unchanged', false),
228
+ exclude_volatile_state_from_prefix: readBoolean(promptCache, 'exclude_volatile_state_from_prefix', false),
229
+ include_content_hashes: readBoolean(promptCache, 'include_content_hashes', false),
230
+ max_stable_prefix_kb: readNumber(promptCache, 'max_stable_prefix_kb'),
231
+ max_task_context_kb: readNumber(promptCache, 'max_task_context_kb'),
232
+ max_volatile_suffix_kb: readNumber(promptCache, 'max_volatile_suffix_kb'),
233
+ };
234
+ }
235
+ function readPromptCacheLayer(mustflow, name) {
236
+ const promptCache = readNestedTable(mustflow, 'prompt_cache');
237
+ const layers = readNestedTable(promptCache, 'layers');
238
+ return readNestedTable(layers, name);
239
+ }
240
+ function readStablePromptCacheLayer(projectRoot, mustflow) {
241
+ const promptCache = readNestedTable(mustflow, 'prompt_cache');
242
+ const layer = readPromptCacheLayer(mustflow, 'stable');
243
+ const volatileLayer = readPromptCacheLayer(mustflow, 'volatile');
244
+ const read = readOptionalStringArray(layer, 'read') ?? [...DEFAULT_PROMPT_CACHE_STABLE_READ];
245
+ const documents = read.map((relativePath) => {
246
+ const content = safeRead(projectRoot, relativePath);
247
+ return {
248
+ path: toPosixPath(relativePath),
249
+ exists: content !== null,
250
+ content_hash: content === null ? null : sha256(content),
251
+ };
252
+ });
253
+ const cacheMaterial = documents
254
+ .map((document) => `${document.path}\0${document.content_hash ?? 'missing'}`)
255
+ .join('\n');
256
+ return {
257
+ cache_layer: 'stable',
258
+ cache_key: documents.length === 0 ? null : sha256(cacheMaterial),
259
+ policy: readOptionalString(promptCache, 'stable_prefix_policy'),
260
+ documents,
261
+ volatile_excluded: readOptionalStringArray(volatileLayer, 'sources') ?? [...DEFAULT_PROMPT_CACHE_VOLATILE_SOURCES],
262
+ };
263
+ }
264
+ function readTaskPromptCacheLayer(mustflow) {
265
+ const layer = readPromptCacheLayer(mustflow, 'task');
266
+ return {
267
+ cache_layer: 'task',
268
+ read_policy: readOptionalString(layer, 'read_policy'),
269
+ sources: readOptionalStringArray(layer, 'sources') ?? [...DEFAULT_PROMPT_CACHE_TASK_SOURCES],
270
+ };
271
+ }
272
+ function readVolatilePromptCacheLayer(mustflow) {
273
+ const layer = readPromptCacheLayer(mustflow, 'volatile');
274
+ return {
275
+ cache_layer: 'volatile',
276
+ sources: readOptionalStringArray(layer, 'sources') ?? [...DEFAULT_PROMPT_CACHE_VOLATILE_SOURCES],
277
+ never_place_before_stable_prefix: readBoolean(layer, 'never_place_before_stable_prefix', false),
278
+ include_absolute_root: false,
279
+ include_latest_run: false,
280
+ };
281
+ }
282
+ export function getPromptCacheProfileContext(projectRoot, profile) {
283
+ const mustflow = readTomlTableIfExists(projectRoot, MUSTFLOW_RELATIVE_PATH);
284
+ const lockInspection = inspectManifestLock(projectRoot);
285
+ const output = {
286
+ schema_version: CONTEXT_SCHEMA_VERSION,
287
+ command: 'context',
288
+ cache_profile: profile,
289
+ prompt_cache: readPromptCacheSettings(mustflow),
290
+ issues: lockInspection.issues,
291
+ };
292
+ if (profile === 'stable' || profile === 'all') {
293
+ return {
294
+ ...output,
295
+ stable_prefix: readStablePromptCacheLayer(projectRoot, mustflow),
296
+ ...(profile === 'all'
297
+ ? {
298
+ task_context: readTaskPromptCacheLayer(mustflow),
299
+ volatile_suffix: readVolatilePromptCacheLayer(mustflow),
300
+ }
301
+ : {}),
302
+ };
303
+ }
304
+ if (profile === 'task') {
305
+ return {
306
+ ...output,
307
+ task_context: readTaskPromptCacheLayer(mustflow),
308
+ };
309
+ }
310
+ return {
311
+ ...output,
312
+ volatile_suffix: readVolatilePromptCacheLayer(mustflow),
313
+ };
314
+ }
315
+ export function getAgentContext(projectRoot) {
316
+ const mustflow = readTomlTableIfExists(projectRoot, MUSTFLOW_RELATIVE_PATH);
317
+ const preferences = readTomlTableIfExists(projectRoot, PREFERENCES_RELATIVE_PATH);
318
+ const authority = isRecord(mustflow?.authority) ? mustflow.authority : undefined;
319
+ const capabilities = isRecord(mustflow?.capabilities) ? mustflow.capabilities : undefined;
320
+ const readOrder = mustflow ? readStringArray(mustflow, 'read_order') ?? [] : [];
321
+ const optionalReadOrder = mustflow ? readStringArray(mustflow, 'optional_read_order') ?? [] : [];
322
+ const lockInspection = inspectManifestLock(projectRoot);
323
+ const lock = lockInspection.readResult.kind === 'present' ? lockInspection.readResult.lock : undefined;
324
+ return {
325
+ schema_version: CONTEXT_SCHEMA_VERSION,
326
+ command: 'context',
327
+ mustflow_root: path.resolve(projectRoot),
328
+ installed: safeExists(projectRoot, 'AGENTS.md') && safeExists(projectRoot, '.mustflow'),
329
+ manifest_lock: lockInspection.readResult.kind,
330
+ template: lock ? { id: lock.templateId, version: lock.templateVersion } : null,
331
+ authority: readScalarObject(authority),
332
+ capabilities: readScalarObject(capabilities),
333
+ read_order: readPathContext(projectRoot, readOrder),
334
+ optional_read_order: readPathContext(projectRoot, optionalReadOrder),
335
+ command_contract: readCommandContractContext(projectRoot),
336
+ effective_policy: readEffectivePolicyContext(mustflow, preferences),
337
+ state_policy: readStatePolicyContext(),
338
+ blocked_actions: BLOCKED_ACTIONS,
339
+ latest_run: readLatestRunContext(projectRoot),
340
+ issues: lockInspection.issues,
341
+ };
342
+ }
@@ -0,0 +1,58 @@
1
+ import { spawn } from 'node:child_process';
2
+ function spawnDetached(bin, args) {
3
+ return spawn(bin, [...args], {
4
+ detached: true,
5
+ stdio: 'ignore',
6
+ windowsHide: true,
7
+ });
8
+ }
9
+ export function getBrowserOpenCommand(url, platform = process.platform) {
10
+ if (platform === 'win32') {
11
+ return { bin: 'cmd', args: ['/c', 'start', '', url] };
12
+ }
13
+ if (platform === 'darwin') {
14
+ return { bin: 'open', args: [url] };
15
+ }
16
+ if (platform === 'linux' || platform === 'freebsd' || platform === 'openbsd') {
17
+ return { bin: 'xdg-open', args: [url] };
18
+ }
19
+ return undefined;
20
+ }
21
+ export function getFileManagerOpenCommand(targetPath, platform = process.platform) {
22
+ if (platform === 'win32') {
23
+ return { bin: 'cmd', args: ['/c', 'start', '', targetPath] };
24
+ }
25
+ if (platform === 'darwin') {
26
+ return { bin: 'open', args: [targetPath] };
27
+ }
28
+ if (platform === 'linux' || platform === 'freebsd' || platform === 'openbsd') {
29
+ return { bin: 'xdg-open', args: [targetPath] };
30
+ }
31
+ return undefined;
32
+ }
33
+ export function openUrlInBrowser(url, options = {}) {
34
+ const command = getBrowserOpenCommand(url, options.platform);
35
+ if (!command) {
36
+ return false;
37
+ }
38
+ const spawnProcess = options.spawnProcess ?? spawnDetached;
39
+ const child = spawnProcess(command.bin, command.args);
40
+ child.once('error', () => {
41
+ // The dashboard URL is still printed, so browser-open failure must not stop the server.
42
+ });
43
+ child.unref();
44
+ return true;
45
+ }
46
+ export function openPathInFileManager(targetPath, options = {}) {
47
+ const command = getFileManagerOpenCommand(targetPath, options.platform);
48
+ if (!command) {
49
+ return false;
50
+ }
51
+ const spawnProcess = options.spawnProcess ?? spawnDetached;
52
+ const child = spawnProcess(command.bin, command.args);
53
+ child.once('error', () => {
54
+ // The dashboard can report the failure through the API response path.
55
+ });
56
+ child.unref();
57
+ return true;
58
+ }
@@ -0,0 +1,36 @@
1
+ import { t } from './i18n.js';
2
+ function renderEntries(entries) {
3
+ const width = Math.max(...entries.map((entry) => entry.label.length));
4
+ return entries.map((entry) => ` ${entry.label.padEnd(width)} ${entry.description}`).join('\n');
5
+ }
6
+ function pushEntrySection(lines, title, entries) {
7
+ if (!entries || entries.length === 0) {
8
+ return;
9
+ }
10
+ lines.push(`${title}:`, renderEntries(entries), '');
11
+ }
12
+ function pushExamples(lines, title, examples) {
13
+ if (!examples || examples.length === 0) {
14
+ return;
15
+ }
16
+ lines.push(`${title}:`, ...examples.map((example) => ` ${example}`), '');
17
+ }
18
+ export function renderHelp(spec, lang = 'en') {
19
+ const lines = [`${t(lang, 'cli.heading.usage')}: ${spec.usage}`, ''];
20
+ if (spec.summary) {
21
+ lines.push(spec.summary, '');
22
+ }
23
+ pushEntrySection(lines, t(lang, 'cli.heading.commands'), spec.commands);
24
+ pushEntrySection(lines, t(lang, 'cli.heading.topics'), spec.topics);
25
+ pushEntrySection(lines, t(lang, 'cli.heading.options'), spec.options);
26
+ pushExamples(lines, t(lang, 'cli.heading.examples'), spec.examples);
27
+ pushEntrySection(lines, t(lang, 'cli.heading.exitCodes'), spec.exitCodes);
28
+ return `${lines.join('\n').trimEnd()}\n`;
29
+ }
30
+ export function renderCliError(message, helpCommand, lang = 'en') {
31
+ return t(lang, 'cli.error.withUsage', { message, helpCommand });
32
+ }
33
+ export function printUsageError(reporter, message, helpCommand, helpText, lang = 'en') {
34
+ reporter.stderr(renderCliError(message, helpCommand, lang));
35
+ reporter.stdout(helpText);
36
+ }
@@ -0,0 +1 @@
1
+ export { COMMAND_LIFECYCLES, COMMAND_RUN_POLICIES, LONG_RUNNING_LIFECYCLES, readCommandContract, readPositiveInteger, readString, readStringArray, resolveMustflowConfigPath, isRecord, } from '../../core/config-loading.js';