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,265 @@
1
+ import { existsSync, readFileSync } from 'node:fs';
2
+ import path from 'node:path';
3
+ import { isRecord } from './command-contract.js';
4
+ import { readTomlFile } from './toml.js';
5
+ const REQUIRED_STATUS_VALUES = ['current', 'stale', 'needs_review', 'missing'];
6
+ function hasOwn(table, key) {
7
+ return Object.prototype.hasOwnProperty.call(table, key);
8
+ }
9
+ function isPositiveInteger(value) {
10
+ return Number.isInteger(value) && Number(value) > 0;
11
+ }
12
+ function isSafeRelativePath(value) {
13
+ if (typeof value !== 'string' || value.trim().length === 0) {
14
+ return false;
15
+ }
16
+ const normalized = value.replace(/\\/g, '/');
17
+ const segments = normalized.split('/').filter(Boolean);
18
+ if (path.posix.isAbsolute(normalized) || path.win32.isAbsolute(value)) {
19
+ return false;
20
+ }
21
+ return segments.length > 0 && segments.every((segment) => segment !== '.' && segment !== '..');
22
+ }
23
+ function readTable(table, key, label, issues) {
24
+ if (!hasOwn(table, key)) {
25
+ issues.push(`${label} is required`);
26
+ return undefined;
27
+ }
28
+ const value = table[key];
29
+ if (!isRecord(value)) {
30
+ issues.push(`${label} must be a TOML table`);
31
+ return undefined;
32
+ }
33
+ return value;
34
+ }
35
+ function readOptionalTable(table, key, label, issues) {
36
+ if (!hasOwn(table, key)) {
37
+ return undefined;
38
+ }
39
+ const value = table[key];
40
+ if (!isRecord(value)) {
41
+ issues.push(`${label} must be a TOML table`);
42
+ return undefined;
43
+ }
44
+ return value;
45
+ }
46
+ function readString(table, key, label, issues) {
47
+ if (typeof table[key] !== 'string' || table[key].trim().length === 0) {
48
+ issues.push(`${label} must be a string`);
49
+ return undefined;
50
+ }
51
+ return table[key];
52
+ }
53
+ function readPositiveInteger(table, key, label, issues) {
54
+ if (!isPositiveInteger(table[key])) {
55
+ issues.push(`${label} must be a positive integer`);
56
+ return undefined;
57
+ }
58
+ return table[key];
59
+ }
60
+ function readStringArray(table, key, label, issues) {
61
+ const value = table[key];
62
+ if (!Array.isArray(value) || value.length === 0 || value.some((entry) => typeof entry !== 'string' || entry.trim().length === 0)) {
63
+ issues.push(`${label} must be a non-empty string array`);
64
+ return undefined;
65
+ }
66
+ return value;
67
+ }
68
+ function validateExistingTemplatePath(templateRoot, relativePath, label, issues) {
69
+ if (!isSafeRelativePath(relativePath)) {
70
+ issues.push(`${label} must be a non-empty relative path`);
71
+ return undefined;
72
+ }
73
+ if (!existsSync(path.join(templateRoot, ...relativePath.split('/')))) {
74
+ issues.push(`${label} points to a missing file: ${relativePath}`);
75
+ return undefined;
76
+ }
77
+ return relativePath;
78
+ }
79
+ function parseMarkdownFrontmatter(filePath) {
80
+ const content = readFileSync(filePath, 'utf8');
81
+ if (!content.startsWith('---\n') && !content.startsWith('---\r\n')) {
82
+ return undefined;
83
+ }
84
+ const frontmatterStart = content.startsWith('---\r\n') ? 5 : 4;
85
+ const endMatch = /\r?\n---(?:\r?\n|$)/u.exec(content.slice(frontmatterStart));
86
+ if (!endMatch || endMatch.index === undefined) {
87
+ return undefined;
88
+ }
89
+ const frontmatter = {};
90
+ const endIndex = frontmatterStart + endMatch.index;
91
+ const lines = content.slice(frontmatterStart, endIndex).split(/\r?\n/u);
92
+ for (const line of lines) {
93
+ const match = /^([A-Za-z0-9_.-]+):\s*(.*?)\s*$/u.exec(line);
94
+ if (!match) {
95
+ continue;
96
+ }
97
+ frontmatter[match[1]] = match[2].replace(/^"(.*)"$/u, '$1');
98
+ }
99
+ return frontmatter;
100
+ }
101
+ function validateFrontmatterField(frontmatter, key, expected, label, issues) {
102
+ if (frontmatter[key] !== expected) {
103
+ issues.push(`${label}.frontmatter.${key} must be ${expected}`);
104
+ }
105
+ }
106
+ function validateMarkdownFrontmatter(templateRoot, relativePath, label, expectedDocumentId, expectedLocale, expectedCanonical, expectedRevision, issues) {
107
+ if (!relativePath.endsWith('.md')) {
108
+ return;
109
+ }
110
+ const absolutePath = path.join(templateRoot, ...relativePath.split('/'));
111
+ const frontmatter = parseMarkdownFrontmatter(absolutePath);
112
+ if (!frontmatter) {
113
+ issues.push(`${label}.frontmatter is required`);
114
+ return;
115
+ }
116
+ validateFrontmatterField(frontmatter, 'mustflow_doc', expectedDocumentId, label, issues);
117
+ validateFrontmatterField(frontmatter, 'locale', expectedLocale, label, issues);
118
+ validateFrontmatterField(frontmatter, 'canonical', String(expectedCanonical), label, issues);
119
+ if (expectedRevision !== undefined) {
120
+ validateFrontmatterField(frontmatter, 'revision', String(expectedRevision), label, issues);
121
+ }
122
+ else if (!isPositiveInteger(Number(frontmatter.revision))) {
123
+ issues.push(`${label}.frontmatter.revision must be a positive integer`);
124
+ }
125
+ }
126
+ function readTomlTable(filePath, label, issues) {
127
+ try {
128
+ const parsed = readTomlFile(filePath);
129
+ if (!isRecord(parsed)) {
130
+ issues.push(`${label} must contain a TOML table`);
131
+ return undefined;
132
+ }
133
+ return parsed;
134
+ }
135
+ catch (error) {
136
+ const message = error instanceof Error ? error.message : String(error);
137
+ issues.push(`Invalid TOML in ${label}: ${message}`);
138
+ return undefined;
139
+ }
140
+ }
141
+ function isLocalizedSourcePath(template, sourcePath, sourceLocale) {
142
+ if (!template.manifest.localesRoot) {
143
+ return false;
144
+ }
145
+ return sourcePath.replace(/\\/g, '/').startsWith(`${template.manifest.localesRoot}/${sourceLocale}/`);
146
+ }
147
+ function validateTranslationPathPrefix(template, documentSourcePath, sourceLocale, translationLocale, translationPath, issues) {
148
+ if (!isLocalizedSourcePath(template, documentSourcePath, sourceLocale) || !template.manifest.localesRoot) {
149
+ return;
150
+ }
151
+ const expectedPrefix = `${template.manifest.localesRoot}/${translationLocale}/`;
152
+ if (!translationPath.replace(/\\/g, '/').startsWith(expectedPrefix)) {
153
+ issues.push(`[documents.*.translations.${translationLocale}].path must start with ${expectedPrefix}`);
154
+ }
155
+ }
156
+ function validateTranslation(template, documentLabel, documentSourcePath, sourceLocale, revision, statusValues, translationLocale, translation, issues) {
157
+ const label = `${documentLabel}.translations.${translationLocale}`;
158
+ if (!isRecord(translation)) {
159
+ issues.push(`[${label}] must be a TOML table`);
160
+ return;
161
+ }
162
+ if (!template.manifest.locales.includes(translationLocale)) {
163
+ issues.push(`[${label}] locale must be listed in template manifest locales.available`);
164
+ }
165
+ if (translationLocale === sourceLocale) {
166
+ issues.push(`[${label}] locale must not equal the source locale`);
167
+ }
168
+ const status = readString(translation, 'status', `[${label}].status`, issues);
169
+ const sourceRevision = readPositiveInteger(translation, 'source_revision', `[${label}].source_revision`, issues);
170
+ const pathValue = translation.path;
171
+ if (status && !statusValues.has(status)) {
172
+ issues.push(`[${label}].status must be one of ${Array.from(statusValues).join(', ')}`);
173
+ }
174
+ if (revision && sourceRevision && sourceRevision > revision) {
175
+ issues.push(`[${label}].source_revision must not be greater than the source revision`);
176
+ }
177
+ if (status === 'current' && revision && sourceRevision && sourceRevision !== revision) {
178
+ issues.push(`[${label}].source_revision must equal the source revision when status is current`);
179
+ }
180
+ if (status === 'stale' && revision && sourceRevision && sourceRevision >= revision) {
181
+ issues.push(`[${label}].source_revision must be lower than the source revision when status is stale`);
182
+ }
183
+ if (status === 'missing') {
184
+ if (pathValue !== undefined && !isSafeRelativePath(pathValue)) {
185
+ issues.push(`[${label}].path must be a relative path when present`);
186
+ }
187
+ return;
188
+ }
189
+ const translationPath = validateExistingTemplatePath(template.templateRoot, pathValue, `[${label}].path`, issues);
190
+ if (translationPath) {
191
+ validateTranslationPathPrefix(template, documentSourcePath, sourceLocale, translationLocale, translationPath, issues);
192
+ validateMarkdownFrontmatter(template.templateRoot, translationPath, `[${label}]`, documentLabel.replace(/^documents\./u, ''), translationLocale, false, undefined, issues);
193
+ }
194
+ }
195
+ function validateDocument(template, documentId, document, sourceLocale, statusValues, issues) {
196
+ const label = `documents.${documentId}`;
197
+ if (!isRecord(document)) {
198
+ issues.push(`[${label}] must be a TOML table`);
199
+ return;
200
+ }
201
+ const source = validateExistingTemplatePath(template.templateRoot, document.source, `[${label}].source`, issues);
202
+ const documentSourceLocale = readString(document, 'source_locale', `[${label}].source_locale`, issues);
203
+ const revision = readPositiveInteger(document, 'revision', `[${label}].revision`, issues);
204
+ if (documentSourceLocale && documentSourceLocale !== sourceLocale) {
205
+ issues.push(`[${label}].source_locale must equal template source locale ${sourceLocale}`);
206
+ }
207
+ if (source) {
208
+ validateMarkdownFrontmatter(template.templateRoot, source, `[${label}]`, documentId, sourceLocale, true, revision, issues);
209
+ }
210
+ const translations = readOptionalTable(document, 'translations', `[${label}.translations]`, issues);
211
+ if (!translations || !source) {
212
+ return;
213
+ }
214
+ for (const [translationLocale, translation] of Object.entries(translations)) {
215
+ validateTranslation(template, label, source, sourceLocale, revision, statusValues, translationLocale, translation, issues);
216
+ }
217
+ }
218
+ export function validateTemplateI18n(template) {
219
+ const issues = [];
220
+ const manifestToml = readTomlTable(template.manifestPath, 'template manifest', issues);
221
+ if (!manifestToml) {
222
+ return issues;
223
+ }
224
+ const manifestI18n = readTable(manifestToml, 'i18n', '[manifest.i18n]', issues);
225
+ const manifestLocales = readTable(manifestToml, 'locales', '[manifest.locales]', issues);
226
+ if (!manifestI18n || !manifestLocales) {
227
+ return issues;
228
+ }
229
+ const metadataPath = validateExistingTemplatePath(template.templateRoot, manifestI18n.metadata, '[manifest.i18n].metadata', issues);
230
+ const manifestSourceLocale = readString(manifestI18n, 'source_locale', '[manifest.i18n].source_locale', issues);
231
+ const localesSourceLocale = readString(manifestLocales, 'source', '[manifest.locales].source', issues);
232
+ if (!metadataPath) {
233
+ return issues;
234
+ }
235
+ const i18nToml = readTomlTable(path.join(template.templateRoot, ...metadataPath.split('/')), metadataPath, issues);
236
+ if (!i18nToml) {
237
+ return issues;
238
+ }
239
+ readPositiveInteger(i18nToml, 'version', '[i18n].version', issues);
240
+ const sourceLocale = readString(i18nToml, 'source_locale', '[i18n].source_locale', issues);
241
+ const statusValues = readStringArray(i18nToml, 'status_values', '[i18n].status_values', issues);
242
+ const documents = readTable(i18nToml, 'documents', '[i18n.documents]', issues);
243
+ if (sourceLocale && manifestSourceLocale && sourceLocale !== manifestSourceLocale) {
244
+ issues.push('[i18n].source_locale must match [manifest.i18n].source_locale');
245
+ }
246
+ if (sourceLocale && localesSourceLocale && sourceLocale !== localesSourceLocale) {
247
+ issues.push('[i18n].source_locale must match [manifest.locales].source');
248
+ }
249
+ if (sourceLocale && !template.manifest.locales.includes(sourceLocale)) {
250
+ issues.push('[i18n].source_locale must be listed in template manifest locales.available');
251
+ }
252
+ if (!sourceLocale || !statusValues || !documents) {
253
+ return issues;
254
+ }
255
+ for (const requiredStatus of REQUIRED_STATUS_VALUES) {
256
+ if (!statusValues.includes(requiredStatus)) {
257
+ issues.push(`[i18n].status_values must include ${requiredStatus}`);
258
+ }
259
+ }
260
+ const allowedStatuses = new Set(statusValues);
261
+ for (const [documentId, document] of Object.entries(documents)) {
262
+ validateDocument(template, documentId, document, sourceLocale, allowedStatuses, issues);
263
+ }
264
+ return issues;
265
+ }
@@ -0,0 +1,188 @@
1
+ import { existsSync, readFileSync } from 'node:fs';
2
+ import path from 'node:path';
3
+ import { fileURLToPath } from 'node:url';
4
+ import { parse } from 'smol-toml';
5
+ function readStringGroup(raw, label) {
6
+ if (typeof raw !== 'object' || raw === null || Array.isArray(raw)) {
7
+ throw new Error(`Template manifest is missing table: ${label}`);
8
+ }
9
+ const group = raw;
10
+ if (typeof group.default !== 'string') {
11
+ throw new Error(`Template manifest is missing string field: ${label}.default`);
12
+ }
13
+ if (!Array.isArray(group.available) || group.available.some((entry) => typeof entry !== 'string')) {
14
+ throw new Error(`Template manifest is missing string array field: ${label}.available`);
15
+ }
16
+ if (!group.available.includes(group.default)) {
17
+ throw new Error(`Template manifest ${label}.available must include ${label}.default`);
18
+ }
19
+ return {
20
+ defaultValue: group.default,
21
+ available: group.available,
22
+ };
23
+ }
24
+ function readStringArrayTable(raw, label) {
25
+ if (raw === undefined) {
26
+ return {};
27
+ }
28
+ if (typeof raw !== 'object' || raw === null || Array.isArray(raw)) {
29
+ throw new Error(`Template manifest ${label} must be a table`);
30
+ }
31
+ const table = {};
32
+ for (const [key, value] of Object.entries(raw)) {
33
+ if (!Array.isArray(value) || value.some((entry) => typeof entry !== 'string')) {
34
+ throw new Error(`Template manifest ${label}.${key} must be a string array`);
35
+ }
36
+ table[key] = value;
37
+ }
38
+ return table;
39
+ }
40
+ function normalizeTemplateTargetPath(relativePath) {
41
+ return relativePath.replaceAll('\\', '/');
42
+ }
43
+ function skillNameForTemplatePath(relativePath) {
44
+ const match = /^\.mustflow\/skills\/([^/]+)\//u.exec(normalizeTemplateTargetPath(relativePath));
45
+ return match?.[1];
46
+ }
47
+ function templateSkillNames(creates) {
48
+ return [
49
+ ...new Set(creates
50
+ .map((relativePath) => {
51
+ const normalizedPath = normalizeTemplateTargetPath(relativePath);
52
+ const match = /^\.mustflow\/skills\/([^/]+)\/SKILL\.md$/u.exec(normalizedPath);
53
+ return match?.[1];
54
+ })
55
+ .filter((value) => Boolean(value))),
56
+ ].sort();
57
+ }
58
+ function resolveSkillProfileSkills(manifest, profile) {
59
+ return manifest.skillProfiles[profile] ?? templateSkillNames(manifest.creates);
60
+ }
61
+ function shouldIncludeTemplatePath(manifest, relativePath, profile) {
62
+ const normalizedPath = normalizeTemplateTargetPath(relativePath);
63
+ const skillName = skillNameForTemplatePath(normalizedPath);
64
+ if (!skillName) {
65
+ return true;
66
+ }
67
+ return resolveSkillProfileSkills(manifest, profile).includes(skillName);
68
+ }
69
+ function filterSkillIndexContent(content, selectedSkills) {
70
+ const selectedSkillSet = new Set(selectedSkills);
71
+ return content
72
+ .split(/\r?\n/u)
73
+ .filter((line) => {
74
+ const match = /`\.mustflow\/skills\/([^/]+)\/SKILL\.md`/u.exec(line);
75
+ return !match || selectedSkillSet.has(match[1] ?? '');
76
+ })
77
+ .join('\n');
78
+ }
79
+ function isAllowedTemplateCreateTarget(relativePath) {
80
+ const normalizedPath = normalizeTemplateTargetPath(relativePath);
81
+ if (normalizedPath.startsWith('/') ||
82
+ normalizedPath.startsWith('../') ||
83
+ normalizedPath.includes('/../') ||
84
+ normalizedPath.endsWith('/..')) {
85
+ return false;
86
+ }
87
+ return normalizedPath === 'AGENTS.md' || normalizedPath.startsWith('.mustflow/');
88
+ }
89
+ /**
90
+ * mf:anchor cli.templates.install-surface
91
+ * purpose: Keep template installation and update targets inside the mustflow-managed surface.
92
+ * search: template manifest, creates, AGENTS.md, .mustflow, install surface
93
+ * invariant: Template creates targets are limited to AGENTS.md and .mustflow paths.
94
+ * risk: config, security
95
+ */
96
+ function validateTemplateCreateTargets(creates) {
97
+ const invalidTarget = creates.find((relativePath) => !isAllowedTemplateCreateTarget(relativePath));
98
+ if (!invalidTarget) {
99
+ return;
100
+ }
101
+ throw new Error(`Template manifest creates target "${invalidTarget}" outside the mustflow-managed install surface. ` +
102
+ 'Template installation and updates may write only AGENTS.md and .mustflow/**.');
103
+ }
104
+ function readManifest(manifestPath) {
105
+ const raw = parse(readFileSync(manifestPath, 'utf8'));
106
+ if (typeof raw.id !== 'string') {
107
+ throw new Error(`Template manifest is missing string field: id`);
108
+ }
109
+ if (typeof raw.version !== 'string') {
110
+ throw new Error(`Template manifest is missing string field: version`);
111
+ }
112
+ if (!Array.isArray(raw.creates) || raw.creates.some((entry) => typeof entry !== 'string')) {
113
+ throw new Error(`Template manifest is missing string array field: creates`);
114
+ }
115
+ validateTemplateCreateTargets(raw.creates);
116
+ const profiles = readStringGroup(raw.profiles, 'profiles');
117
+ const locales = readStringGroup(raw.locales, 'locales');
118
+ const commonRoot = typeof raw.common_root === 'string' ? raw.common_root : raw.files_root;
119
+ const skillProfiles = readStringArrayTable(raw.skill_profiles, 'skill_profiles');
120
+ const availableSkillNames = new Set(templateSkillNames(raw.creates));
121
+ if (typeof commonRoot !== 'string') {
122
+ throw new Error(`Template manifest is missing string field: common_root`);
123
+ }
124
+ if (raw.locales_root !== undefined && typeof raw.locales_root !== 'string') {
125
+ throw new Error(`Template manifest locales_root must be a string when present`);
126
+ }
127
+ for (const [profile, skills] of Object.entries(skillProfiles)) {
128
+ if (!profiles.available.includes(profile)) {
129
+ throw new Error(`Template manifest skill_profiles.${profile} is not listed in profiles.available`);
130
+ }
131
+ for (const skill of skills) {
132
+ if (!availableSkillNames.has(skill)) {
133
+ throw new Error(`Template manifest skill_profiles.${profile} references unknown skill: ${skill}`);
134
+ }
135
+ }
136
+ }
137
+ return {
138
+ id: raw.id,
139
+ version: raw.version,
140
+ commonRoot,
141
+ localesRoot: raw.locales_root,
142
+ creates: raw.creates,
143
+ defaultProfile: profiles.defaultValue,
144
+ profiles: profiles.available,
145
+ skillProfiles,
146
+ defaultLocale: locales.defaultValue,
147
+ locales: locales.available,
148
+ };
149
+ }
150
+ export function getDefaultTemplate() {
151
+ const templateRoot = path.resolve(process.env.MUSTFLOW_DEV_TEMPLATE_ROOT ?? fileURLToPath(new URL('../../../templates/default', import.meta.url)));
152
+ const manifestPath = path.join(templateRoot, 'manifest.toml');
153
+ const manifest = readManifest(manifestPath);
154
+ return {
155
+ manifestPath,
156
+ templateRoot,
157
+ manifest,
158
+ };
159
+ }
160
+ export function getTemplateFiles(template, locale = template.manifest.defaultLocale, profile = template.manifest.defaultProfile) {
161
+ const commonRoot = path.join(template.templateRoot, template.manifest.commonRoot);
162
+ const localeRoot = template.manifest.localesRoot ? path.join(template.templateRoot, template.manifest.localesRoot, locale) : undefined;
163
+ const selectedSkills = resolveSkillProfileSkills(template.manifest, profile);
164
+ return template.manifest.creates.filter((relativePath) => shouldIncludeTemplatePath(template.manifest, relativePath, profile)).map((relativePath) => {
165
+ const localePath = localeRoot ? path.join(localeRoot, ...relativePath.split('/')) : undefined;
166
+ const commonPath = path.join(commonRoot, ...relativePath.split('/'));
167
+ const content = relativePath === '.mustflow/skills/INDEX.md'
168
+ ? filterSkillIndexContent(readFileSync(localePath && existsSync(localePath) ? localePath : commonPath, 'utf8'), selectedSkills)
169
+ : undefined;
170
+ if (localePath && existsSync(localePath)) {
171
+ return {
172
+ relativePath,
173
+ sourcePath: localePath,
174
+ sourceKind: 'locale',
175
+ content,
176
+ };
177
+ }
178
+ if (existsSync(commonPath)) {
179
+ return {
180
+ relativePath,
181
+ sourcePath: commonPath,
182
+ sourceKind: template.manifest.localesRoot ? 'common' : 'legacy',
183
+ content,
184
+ };
185
+ }
186
+ throw new Error(`Template source missing for ${relativePath} in locale ${locale}`);
187
+ });
188
+ }
@@ -0,0 +1 @@
1
+ export { parseTomlText, readTomlFile, stringifyToml } from '../../core/toml.js';