bmad-method 6.12.4 → 7.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (389) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +107 -54
  3. package/agents.json +640 -0
  4. package/bin/bmad-method.js +4 -0
  5. package/messages.yaml +260 -0
  6. package/modules.yaml +56 -0
  7. package/package.json +32 -110
  8. package/src/agent-picks.js +77 -0
  9. package/src/agents.js +141 -0
  10. package/src/bmad-scripts.js +167 -0
  11. package/src/cli.js +266 -0
  12. package/src/commands/agent-choice.js +67 -0
  13. package/src/commands/apply.js +38 -0
  14. package/src/commands/deps.js +25 -0
  15. package/src/commands/ending.js +54 -0
  16. package/src/commands/existing-install.js +50 -0
  17. package/src/commands/install-plan.js +130 -0
  18. package/src/commands/install-steps.js +66 -0
  19. package/src/commands/install.js +86 -0
  20. package/src/commands/status.js +39 -0
  21. package/src/commands/update.js +106 -0
  22. package/src/installed.js +48 -0
  23. package/src/messages.js +84 -0
  24. package/src/modules.js +221 -0
  25. package/src/preflight.js +124 -0
  26. package/src/project-lock.js +68 -0
  27. package/src/prompts.js +626 -0
  28. package/src/report.js +199 -0
  29. package/src/run.js +124 -0
  30. package/src/self-update.js +88 -0
  31. package/src/skills-cli.js +133 -0
  32. package/src/version.js +11 -0
  33. package/.claude-plugin/marketplace.json +0 -53
  34. package/AGENTS.md +0 -24
  35. package/CLAUDE.md +0 -1
  36. package/README_CN.md +0 -98
  37. package/README_KR.md +0 -90
  38. package/README_VN.md +0 -99
  39. package/bmad-modules.yaml +0 -140
  40. package/body.md +0 -17
  41. package/greptile.json +0 -52
  42. package/pr2.md +0 -11
  43. package/removals.txt +0 -87
  44. package/src/bmm-skills/agents/bmad-agent-analyst/SKILL.md +0 -76
  45. package/src/bmm-skills/agents/bmad-agent-analyst/customize.toml +0 -103
  46. package/src/bmm-skills/agents/bmad-agent-architect/SKILL.md +0 -76
  47. package/src/bmm-skills/agents/bmad-agent-architect/customize.toml +0 -63
  48. package/src/bmm-skills/agents/bmad-agent-dev/SKILL.md +0 -76
  49. package/src/bmm-skills/agents/bmad-agent-dev/customize.toml +0 -81
  50. package/src/bmm-skills/agents/bmad-agent-pm/SKILL.md +0 -76
  51. package/src/bmm-skills/agents/bmad-agent-pm/customize.toml +0 -73
  52. package/src/bmm-skills/agents/bmad-agent-ux-designer/SKILL.md +0 -76
  53. package/src/bmm-skills/agents/bmad-agent-ux-designer/customize.toml +0 -58
  54. package/src/bmm-skills/module-help.csv +0 -19
  55. package/src/bmm-skills/module.yaml +0 -85
  56. package/src/bmm-skills/plan/bmad-architecture/SKILL.md +0 -85
  57. package/src/bmm-skills/plan/bmad-architecture/assets/spine-template.md +0 -79
  58. package/src/bmm-skills/plan/bmad-architecture/customize.toml +0 -101
  59. package/src/bmm-skills/plan/bmad-architecture/references/headless.md +0 -26
  60. package/src/bmm-skills/plan/bmad-architecture/references/reviewer-gate.md +0 -13
  61. package/src/bmm-skills/plan/bmad-architecture/scripts/lint_spine.py +0 -261
  62. package/src/bmm-skills/plan/bmad-architecture/scripts/tests/test_lint_spine.py +0 -270
  63. package/src/bmm-skills/plan/bmad-create-epics-and-stories/SKILL.md +0 -93
  64. package/src/bmm-skills/plan/bmad-create-epics-and-stories/customize.toml +0 -39
  65. package/src/bmm-skills/plan/bmad-create-epics-and-stories/steps/step-01-validate-prerequisites.md +0 -263
  66. package/src/bmm-skills/plan/bmad-create-epics-and-stories/steps/step-02-design-epics.md +0 -242
  67. package/src/bmm-skills/plan/bmad-create-epics-and-stories/steps/step-03-create-stories.md +0 -255
  68. package/src/bmm-skills/plan/bmad-create-epics-and-stories/steps/step-04-final-validation.md +0 -141
  69. package/src/bmm-skills/plan/bmad-create-epics-and-stories/templates/epics-template.md +0 -62
  70. package/src/bmm-skills/plan/bmad-generate-project-context/SKILL.md +0 -12
  71. package/src/bmm-skills/plan/bmad-prd/SKILL.md +0 -94
  72. package/src/bmm-skills/plan/bmad-prd/assets/headless-schemas.md +0 -76
  73. package/src/bmm-skills/plan/bmad-prd/assets/prd-template.md +0 -165
  74. package/src/bmm-skills/plan/bmad-prd/assets/prd-validation-checklist.md +0 -135
  75. package/src/bmm-skills/plan/bmad-prd/assets/validation-report-template.html +0 -325
  76. package/src/bmm-skills/plan/bmad-prd/customize.toml +0 -148
  77. package/src/bmm-skills/plan/bmad-prd/references/headless.md +0 -39
  78. package/src/bmm-skills/plan/bmad-prd/references/validate.md +0 -97
  79. package/src/bmm-skills/plan/bmad-prfaq/SKILL.md +0 -135
  80. package/src/bmm-skills/plan/bmad-prfaq/agents/artifact-analyzer.md +0 -60
  81. package/src/bmm-skills/plan/bmad-prfaq/agents/web-researcher.md +0 -49
  82. package/src/bmm-skills/plan/bmad-prfaq/assets/prfaq-template.md +0 -62
  83. package/src/bmm-skills/plan/bmad-prfaq/bmad-manifest.json +0 -16
  84. package/src/bmm-skills/plan/bmad-prfaq/customize.toml +0 -39
  85. package/src/bmm-skills/plan/bmad-prfaq/references/customer-faq.md +0 -55
  86. package/src/bmm-skills/plan/bmad-prfaq/references/internal-faq.md +0 -51
  87. package/src/bmm-skills/plan/bmad-prfaq/references/press-release.md +0 -60
  88. package/src/bmm-skills/plan/bmad-prfaq/references/verdict.md +0 -83
  89. package/src/bmm-skills/plan/bmad-product-brief/SKILL.md +0 -91
  90. package/src/bmm-skills/plan/bmad-product-brief/assets/brief-template.md +0 -41
  91. package/src/bmm-skills/plan/bmad-product-brief/customize.toml +0 -100
  92. package/src/bmm-skills/plan/bmad-project-context/SKILL.md +0 -121
  93. package/src/bmm-skills/plan/bmad-project-context/customize.toml +0 -24
  94. package/src/bmm-skills/plan/bmad-project-context/references/best-practices.md +0 -84
  95. package/src/bmm-skills/plan/bmad-project-context/references/template.md +0 -55
  96. package/src/bmm-skills/plan/bmad-spec/SKILL.md +0 -160
  97. package/src/bmm-skills/plan/bmad-spec/assets/headless-schemas.md +0 -33
  98. package/src/bmm-skills/plan/bmad-spec/assets/spec-template.md +0 -49
  99. package/src/bmm-skills/plan/bmad-spec/assets/stories-schema.md +0 -44
  100. package/src/bmm-skills/plan/bmad-spec/customize.toml +0 -52
  101. package/src/bmm-skills/plan/bmad-sprint-planning/SKILL.md +0 -62
  102. package/src/bmm-skills/plan/bmad-sprint-planning/customize.toml +0 -39
  103. package/src/bmm-skills/plan/bmad-sprint-planning/references/fix-sprint-status.md +0 -30
  104. package/src/bmm-skills/plan/bmad-sprint-planning/references/generate-tracking.md +0 -25
  105. package/src/bmm-skills/plan/bmad-sprint-planning/references/readiness-gate.md +0 -20
  106. package/src/bmm-skills/plan/bmad-sprint-planning/references/status-view.md +0 -14
  107. package/src/bmm-skills/plan/bmad-sprint-planning/references/validate.md +0 -10
  108. package/src/bmm-skills/plan/bmad-sprint-planning/scripts/__pycache__/sprint_plan.cpython-311.pyc +0 -0
  109. package/src/bmm-skills/plan/bmad-sprint-planning/scripts/sprint_plan.py +0 -701
  110. package/src/bmm-skills/plan/bmad-sprint-planning/scripts/tests/__pycache__/test_sprint_plan.cpython-311-pytest-9.1.1.pyc +0 -0
  111. package/src/bmm-skills/plan/bmad-sprint-planning/scripts/tests/test_sprint_plan.py +0 -524
  112. package/src/bmm-skills/plan/bmad-sprint-planning/sprint-status-template.yaml +0 -71
  113. package/src/bmm-skills/plan/bmad-ux/SKILL.md +0 -90
  114. package/src/bmm-skills/plan/bmad-ux/assets/color-themes.md +0 -9
  115. package/src/bmm-skills/plan/bmad-ux/assets/design-directions.md +0 -9
  116. package/src/bmm-skills/plan/bmad-ux/assets/design-example-editorial.md +0 -158
  117. package/src/bmm-skills/plan/bmad-ux/assets/design-example-mobile.md +0 -93
  118. package/src/bmm-skills/plan/bmad-ux/assets/design-example-shadcn.md +0 -109
  119. package/src/bmm-skills/plan/bmad-ux/assets/excalidraw-wireframe.md +0 -19
  120. package/src/bmm-skills/plan/bmad-ux/assets/experience-example-mobile.md +0 -112
  121. package/src/bmm-skills/plan/bmad-ux/assets/experience-example-shadcn.md +0 -133
  122. package/src/bmm-skills/plan/bmad-ux/assets/headless-schemas.md +0 -84
  123. package/src/bmm-skills/plan/bmad-ux/assets/key-screens.md +0 -29
  124. package/src/bmm-skills/plan/bmad-ux/assets/validation-report-template.html +0 -319
  125. package/src/bmm-skills/plan/bmad-ux/customize.toml +0 -100
  126. package/src/bmm-skills/plan/bmad-ux/references/creative-tools.md +0 -19
  127. package/src/bmm-skills/plan/bmad-ux/references/design-md-spec.md +0 -50
  128. package/src/bmm-skills/plan/bmad-ux/references/headless.md +0 -37
  129. package/src/bmm-skills/plan/bmad-ux/references/validate.md +0 -115
  130. package/src/bmm-skills/ship/bmad-build/SKILL.md +0 -13
  131. package/src/bmm-skills/ship/bmad-build/compile-epic-context.md +0 -62
  132. package/src/bmm-skills/ship/bmad-build/customize.toml +0 -152
  133. package/src/bmm-skills/ship/bmad-build/references/claims-check.md +0 -14
  134. package/src/bmm-skills/ship/bmad-build/references/deletion-check.md +0 -14
  135. package/src/bmm-skills/ship/bmad-build/review-prompts/edge-case-hunter.md +0 -112
  136. package/src/bmm-skills/ship/bmad-build/review-prompts/verification-gap.md +0 -113
  137. package/src/bmm-skills/ship/bmad-build/spec-template.md +0 -111
  138. package/src/bmm-skills/ship/bmad-build/step-01-clarify-and-route.md +0 -100
  139. package/src/bmm-skills/ship/bmad-build/step-02-plan.md +0 -62
  140. package/src/bmm-skills/ship/bmad-build/step-03-implement.md +0 -51
  141. package/src/bmm-skills/ship/bmad-build/step-04-review.md +0 -85
  142. package/src/bmm-skills/ship/bmad-build/step-05-present.md +0 -43
  143. package/src/bmm-skills/ship/bmad-build/step-oneshot.md +0 -107
  144. package/src/bmm-skills/ship/bmad-build/sync-sprint-status.md +0 -5
  145. package/src/bmm-skills/ship/bmad-build/workflow.md +0 -84
  146. package/src/bmm-skills/ship/bmad-build-auto/SKILL.md +0 -13
  147. package/src/bmm-skills/ship/bmad-build-auto/compile-epic-context.md +0 -62
  148. package/src/bmm-skills/ship/bmad-build-auto/customize.toml +0 -119
  149. package/src/bmm-skills/ship/bmad-build-auto/references/claims-check.md +0 -14
  150. package/src/bmm-skills/ship/bmad-build-auto/references/deletion-check.md +0 -14
  151. package/src/bmm-skills/ship/bmad-build-auto/review-prompts/edge-case-hunter.md +0 -112
  152. package/src/bmm-skills/ship/bmad-build-auto/review-prompts/verification-gap.md +0 -113
  153. package/src/bmm-skills/ship/bmad-build-auto/spec-template.md +0 -96
  154. package/src/bmm-skills/ship/bmad-build-auto/step-01-clarify-and-route.md +0 -84
  155. package/src/bmm-skills/ship/bmad-build-auto/step-02-plan.md +0 -27
  156. package/src/bmm-skills/ship/bmad-build-auto/step-03-implement.md +0 -48
  157. package/src/bmm-skills/ship/bmad-build-auto/step-04-review.md +0 -116
  158. package/src/bmm-skills/ship/bmad-build-auto/workflow.md +0 -104
  159. package/src/bmm-skills/ship/bmad-code-review/SKILL.md +0 -90
  160. package/src/bmm-skills/ship/bmad-code-review/customize.toml +0 -110
  161. package/src/bmm-skills/ship/bmad-code-review/references/claims-check.md +0 -14
  162. package/src/bmm-skills/ship/bmad-code-review/references/deletion-check.md +0 -14
  163. package/src/bmm-skills/ship/bmad-code-review/review-prompts/edge-case-hunter.md +0 -112
  164. package/src/bmm-skills/ship/bmad-code-review/review-prompts/verification-gap.md +0 -113
  165. package/src/bmm-skills/ship/bmad-code-review/steps/step-01-gather-context.md +0 -94
  166. package/src/bmm-skills/ship/bmad-code-review/steps/step-02-review.md +0 -32
  167. package/src/bmm-skills/ship/bmad-code-review/steps/step-03-triage.md +0 -54
  168. package/src/bmm-skills/ship/bmad-code-review/steps/step-04-present.md +0 -134
  169. package/src/bmm-skills/ship/bmad-correct-course/SKILL.md +0 -308
  170. package/src/bmm-skills/ship/bmad-correct-course/checklist.md +0 -288
  171. package/src/bmm-skills/ship/bmad-correct-course/customize.toml +0 -39
  172. package/src/bmm-skills/ship/bmad-qa-generate-e2e-tests/SKILL.md +0 -176
  173. package/src/bmm-skills/ship/bmad-qa-generate-e2e-tests/checklist.md +0 -33
  174. package/src/bmm-skills/ship/bmad-qa-generate-e2e-tests/customize.toml +0 -39
  175. package/src/bmm-skills/ship/bmad-retrospective/SKILL.md +0 -94
  176. package/src/bmm-skills/ship/bmad-retrospective/customize.toml +0 -39
  177. package/src/bmm-skills/ship/bmad-retrospective/references/acceptance-verdict.md +0 -55
  178. package/src/bmm-skills/ship/bmad-retrospective/references/aggregate-views.md +0 -17
  179. package/src/bmm-skills/ship/bmad-retrospective/references/evidence-gathering.md +0 -30
  180. package/src/bmm-skills/ship/bmad-retrospective/references/retro-document.md +0 -84
  181. package/src/bmm-skills/ship/bmad-retrospective/references/team-discussion.md +0 -22
  182. package/src/bmm-skills/ship/bmad-retrospective/scripts/__pycache__/sprint_status.cpython-311.pyc +0 -0
  183. package/src/bmm-skills/ship/bmad-retrospective/scripts/git_evidence.py +0 -308
  184. package/src/bmm-skills/ship/bmad-retrospective/scripts/sprint_status.py +0 -750
  185. package/src/bmm-skills/ship/bmad-retrospective/scripts/tests/__pycache__/test_git_evidence.cpython-311-pytest-9.1.1.pyc +0 -0
  186. package/src/bmm-skills/ship/bmad-retrospective/scripts/tests/__pycache__/test_sprint_status.cpython-311-pytest-9.1.1.pyc +0 -0
  187. package/src/bmm-skills/ship/bmad-retrospective/scripts/tests/fixtures/sprint-status-template.yaml +0 -71
  188. package/src/bmm-skills/ship/bmad-retrospective/scripts/tests/test_git_evidence.py +0 -750
  189. package/src/bmm-skills/ship/bmad-retrospective/scripts/tests/test_sprint_status.py +0 -1579
  190. package/src/bmm-skills/ship/bmad-walkthrough/SKILL.md +0 -68
  191. package/src/bmm-skills/ship/bmad-walkthrough/customize.toml +0 -39
  192. package/src/bmm-skills/ship/bmad-walkthrough/generate-trail.md +0 -38
  193. package/src/bmm-skills/ship/bmad-walkthrough/step-01-orientation.md +0 -105
  194. package/src/bmm-skills/ship/bmad-walkthrough/step-02-walkthrough.md +0 -89
  195. package/src/bmm-skills/ship/bmad-walkthrough/step-03-detail-pass.md +0 -106
  196. package/src/bmm-skills/ship/bmad-walkthrough/step-04-testing.md +0 -74
  197. package/src/bmm-skills/ship/bmad-walkthrough/step-05-wrapup.md +0 -30
  198. package/src/bmm-skills/v6-shims/README.md +0 -29
  199. package/src/bmm-skills/v6-shims/bmad-checkpoint-preview/SKILL.md +0 -21
  200. package/src/bmm-skills/v6-shims/bmad-create-architecture/SKILL.md +0 -32
  201. package/src/bmm-skills/v6-shims/bmad-create-architecture/customize.toml +0 -39
  202. package/src/bmm-skills/v6-shims/bmad-create-prd/SKILL.md +0 -32
  203. package/src/bmm-skills/v6-shims/bmad-create-prd/customize.toml +0 -39
  204. package/src/bmm-skills/v6-shims/bmad-create-story/SKILL.md +0 -436
  205. package/src/bmm-skills/v6-shims/bmad-create-story/checklist.md +0 -357
  206. package/src/bmm-skills/v6-shims/bmad-create-story/customize.toml +0 -39
  207. package/src/bmm-skills/v6-shims/bmad-create-story/discover-inputs.md +0 -88
  208. package/src/bmm-skills/v6-shims/bmad-create-story/template.md +0 -49
  209. package/src/bmm-skills/v6-shims/bmad-dev-auto/SKILL.md +0 -21
  210. package/src/bmm-skills/v6-shims/bmad-dev-story/SKILL.md +0 -504
  211. package/src/bmm-skills/v6-shims/bmad-dev-story/checklist.md +0 -80
  212. package/src/bmm-skills/v6-shims/bmad-dev-story/customize.toml +0 -39
  213. package/src/bmm-skills/v6-shims/bmad-document-project/SKILL.md +0 -16
  214. package/src/bmm-skills/v6-shims/bmad-domain-research/SKILL.md +0 -16
  215. package/src/bmm-skills/v6-shims/bmad-edit-prd/SKILL.md +0 -32
  216. package/src/bmm-skills/v6-shims/bmad-edit-prd/customize.toml +0 -40
  217. package/src/bmm-skills/v6-shims/bmad-market-research/SKILL.md +0 -16
  218. package/src/bmm-skills/v6-shims/bmad-quick-dev/SKILL.md +0 -21
  219. package/src/bmm-skills/v6-shims/bmad-sprint-status/SKILL.md +0 -28
  220. package/src/bmm-skills/v6-shims/bmad-sprint-status/customize.toml +0 -39
  221. package/src/bmm-skills/v6-shims/bmad-technical-research/SKILL.md +0 -16
  222. package/src/bmm-skills/v6-shims/bmad-validate-prd/SKILL.md +0 -32
  223. package/src/bmm-skills/v6-shims/bmad-validate-prd/customize.toml +0 -40
  224. package/src/core-skills/bmad-advanced-elicitation/SKILL.md +0 -64
  225. package/src/core-skills/bmad-advanced-elicitation/assets/methods.csv +0 -72
  226. package/src/core-skills/bmad-advanced-elicitation/customize.toml +0 -54
  227. package/src/core-skills/bmad-advanced-elicitation/scripts/pick_methods.py +0 -233
  228. package/src/core-skills/bmad-advanced-elicitation/scripts/tests/test_pick_methods.py +0 -228
  229. package/src/core-skills/bmad-brainstorming/SKILL.md +0 -80
  230. package/src/core-skills/bmad-brainstorming/assets/brain-icons.json +0 -166
  231. package/src/core-skills/bmad-brainstorming/assets/brain-methods.csv +0 -109
  232. package/src/core-skills/bmad-brainstorming/assets/brain-selector.html +0 -328
  233. package/src/core-skills/bmad-brainstorming/customize.toml +0 -83
  234. package/src/core-skills/bmad-brainstorming/references/converge.md +0 -24
  235. package/src/core-skills/bmad-brainstorming/references/finalize.md +0 -26
  236. package/src/core-skills/bmad-brainstorming/references/headless.md +0 -54
  237. package/src/core-skills/bmad-brainstorming/references/in-chat-techniques.md +0 -18
  238. package/src/core-skills/bmad-brainstorming/references/mode-autonomous.md +0 -10
  239. package/src/core-skills/bmad-brainstorming/references/mode-facilitator.md +0 -11
  240. package/src/core-skills/bmad-brainstorming/references/mode-partner.md +0 -16
  241. package/src/core-skills/bmad-brainstorming/references/resume.md +0 -5
  242. package/src/core-skills/bmad-brainstorming/scripts/brain.py +0 -789
  243. package/src/core-skills/bmad-brainstorming/scripts/tests/test_brain.py +0 -289
  244. package/src/core-skills/bmad-customize/SKILL.md +0 -111
  245. package/src/core-skills/bmad-customize/scripts/list_customizable_skills.py +0 -235
  246. package/src/core-skills/bmad-customize/scripts/tests/test_list_customizable_skills.py +0 -249
  247. package/src/core-skills/bmad-deep-recon/SKILL.md +0 -82
  248. package/src/core-skills/bmad-deep-recon/assets/research.template.md +0 -18
  249. package/src/core-skills/bmad-deep-recon/customize.toml +0 -212
  250. package/src/core-skills/bmad-deep-recon/references/draft.md +0 -8
  251. package/src/core-skills/bmad-deep-recon/references/finalize.md +0 -11
  252. package/src/core-skills/bmad-deep-recon/references/html-briefing.md +0 -16
  253. package/src/core-skills/bmad-deep-recon/references/lifecycle.md +0 -11
  254. package/src/core-skills/bmad-deep-recon/references/process.md +0 -10
  255. package/src/core-skills/bmad-deep-recon/references/run.md +0 -73
  256. package/src/core-skills/bmad-deep-recon/references/selection.md +0 -13
  257. package/src/core-skills/bmad-deep-recon/references/synthesis.md +0 -16
  258. package/src/core-skills/bmad-deep-recon/references/verification.md +0 -29
  259. package/src/core-skills/bmad-deep-recon/scripts/recon_kit.py +0 -326
  260. package/src/core-skills/bmad-deep-recon/scripts/tests/test_recon_kit.py +0 -144
  261. package/src/core-skills/bmad-deep-recon/types/academic-lit.md +0 -19
  262. package/src/core-skills/bmad-deep-recon/types/competitive.md +0 -19
  263. package/src/core-skills/bmad-deep-recon/types/domain.md +0 -19
  264. package/src/core-skills/bmad-deep-recon/types/market.md +0 -19
  265. package/src/core-skills/bmad-deep-recon/types/technical.md +0 -19
  266. package/src/core-skills/bmad-deep-recon/types/user-voice.md +0 -19
  267. package/src/core-skills/bmad-forge-idea/SKILL.md +0 -107
  268. package/src/core-skills/bmad-forge-idea/customize.toml +0 -41
  269. package/src/core-skills/bmad-forge-idea/scripts/resolve_personas.py +0 -277
  270. package/src/core-skills/bmad-forge-idea/scripts/tests/test_resolve_personas.py +0 -160
  271. package/src/core-skills/bmad-help/SKILL.md +0 -77
  272. package/src/core-skills/bmad-party-mode/SKILL.md +0 -60
  273. package/src/core-skills/bmad-party-mode/customize.toml +0 -211
  274. package/src/core-skills/bmad-party-mode/references/create-party.md +0 -70
  275. package/src/core-skills/bmad-party-mode/references/mode-agent-team.md +0 -13
  276. package/src/core-skills/bmad-party-mode/references/mode-auto.md +0 -13
  277. package/src/core-skills/bmad-party-mode/references/mode-subagent.md +0 -31
  278. package/src/core-skills/bmad-party-mode/references/party-memory.md +0 -51
  279. package/src/core-skills/bmad-party-mode/scripts/resolve_party.py +0 -300
  280. package/src/core-skills/bmad-party-mode/scripts/tests/test_resolve_party.py +0 -183
  281. package/src/core-skills/bmad-review/SKILL.md +0 -50
  282. package/src/core-skills/bmad-review/customize.toml +0 -141
  283. package/src/core-skills/bmad-review/references/editorial-common.md +0 -56
  284. package/src/core-skills/bmad-review/references/lens-adversarial.md +0 -19
  285. package/src/core-skills/bmad-review/references/lens-edge-case-hunter.md +0 -72
  286. package/src/core-skills/bmad-review/references/lens-prose.md +0 -7
  287. package/src/core-skills/bmad-review/references/lens-structure.md +0 -9
  288. package/src/core-skills/bmad-review/references/lens-verification-gap.md +0 -92
  289. package/src/core-skills/bmad-review/references/structure-models.md +0 -44
  290. package/src/core-skills/bmad-review/scripts/tests/test_word_metrics.py +0 -62
  291. package/src/core-skills/bmad-review/scripts/word_metrics.py +0 -102
  292. package/src/core-skills/module-help.csv +0 -10
  293. package/src/core-skills/module.yaml +0 -38
  294. package/src/core-skills/v6-shims/README.md +0 -25
  295. package/src/core-skills/v6-shims/bmad-editorial-review/SKILL.md +0 -8
  296. package/src/core-skills/v6-shims/bmad-editorial-review/customize.toml +0 -31
  297. package/src/core-skills/v6-shims/bmad-editorial-review-prose/SKILL.md +0 -8
  298. package/src/core-skills/v6-shims/bmad-editorial-review-structure/SKILL.md +0 -8
  299. package/src/core-skills/v6-shims/bmad-review-adversarial-general/SKILL.md +0 -8
  300. package/src/core-skills/v6-shims/bmad-review-edge-case-hunter/SKILL.md +0 -8
  301. package/src/core-skills/v6-shims/bmad-review-verification-gap/SKILL.md +0 -8
  302. package/src/scripts/__pycache__/config_utils.cpython-311.pyc +0 -0
  303. package/src/scripts/config_utils.py +0 -119
  304. package/src/scripts/memlog.py +0 -228
  305. package/src/scripts/render_skill.py +0 -401
  306. package/src/scripts/resolve_config.py +0 -82
  307. package/src/scripts/resolve_customization.py +0 -164
  308. package/src/scripts/tests/__pycache__/test_config_utils.cpython-311.pyc +0 -0
  309. package/src/scripts/tests/__pycache__/test_resolve_config.cpython-311.pyc +0 -0
  310. package/src/scripts/tests/__pycache__/test_resolve_customization.cpython-311.pyc +0 -0
  311. package/src/scripts/tests/test_config_utils.py +0 -85
  312. package/src/scripts/tests/test_memlog.py +0 -306
  313. package/src/scripts/tests/test_resolve_config.py +0 -117
  314. package/src/scripts/tests/test_resolve_customization.py +0 -179
  315. package/tools/bundle-web-bundles.js +0 -117
  316. package/tools/format-workflow-md.js +0 -263
  317. package/tools/installer/README.md +0 -60
  318. package/tools/installer/bmad-cli.js +0 -105
  319. package/tools/installer/cli-utils.js +0 -57
  320. package/tools/installer/commands/install.js +0 -151
  321. package/tools/installer/commands/status.js +0 -65
  322. package/tools/installer/commands/uninstall.js +0 -167
  323. package/tools/installer/core/config.js +0 -76
  324. package/tools/installer/core/existing-install.js +0 -121
  325. package/tools/installer/core/install-paths.js +0 -132
  326. package/tools/installer/core/installer.js +0 -1826
  327. package/tools/installer/core/legacy-warnings.js +0 -151
  328. package/tools/installer/core/manifest-generator.js +0 -883
  329. package/tools/installer/core/manifest.js +0 -439
  330. package/tools/installer/core/shim-policy.js +0 -159
  331. package/tools/installer/core/uv-check.js +0 -195
  332. package/tools/installer/core/wsl-node-check.js +0 -109
  333. package/tools/installer/file-ops.js +0 -204
  334. package/tools/installer/fs-native.js +0 -116
  335. package/tools/installer/ide/_config-driven.js +0 -972
  336. package/tools/installer/ide/manager.js +0 -324
  337. package/tools/installer/ide/platform-codes.js +0 -80
  338. package/tools/installer/ide/platform-codes.yaml +0 -363
  339. package/tools/installer/ide/shared/installed-skills.js +0 -50
  340. package/tools/installer/ide/shared/path-utils.js +0 -219
  341. package/tools/installer/ide/shared/skill-manifest.js +0 -57
  342. package/tools/installer/install-messages.yaml +0 -44
  343. package/tools/installer/list-options.js +0 -210
  344. package/tools/installer/message-loader.js +0 -83
  345. package/tools/installer/modules/channel-plan.js +0 -216
  346. package/tools/installer/modules/channel-resolver.js +0 -241
  347. package/tools/installer/modules/custom-module-manager.js +0 -924
  348. package/tools/installer/modules/external-manager.js +0 -673
  349. package/tools/installer/modules/git-env.js +0 -47
  350. package/tools/installer/modules/module-help-schema.js +0 -13
  351. package/tools/installer/modules/official-modules.js +0 -2289
  352. package/tools/installer/modules/plugin-resolver.js +0 -398
  353. package/tools/installer/modules/version-resolver.js +0 -336
  354. package/tools/installer/project-root.js +0 -224
  355. package/tools/installer/prompts.js +0 -804
  356. package/tools/installer/set-overrides.js +0 -330
  357. package/tools/installer/ui.js +0 -2262
  358. package/tools/installer/yaml-format.js +0 -245
  359. package/tools/javascript-conventions.md +0 -5
  360. package/tools/migrate-custom-module-paths.js +0 -124
  361. package/tools/skill-validator.md +0 -312
  362. package/tools/tests/__pycache__/test_validate_skills.cpython-311.pyc +0 -0
  363. package/tools/tests/fixtures/validate-skills/bmad/SKILL.md +0 -8
  364. package/tools/tests/fixtures/validate-skills/deprecated-shim/SKILL.md +0 -9
  365. package/tools/tests/fixtures/validate-skills/missing-trigger/SKILL.md +0 -9
  366. package/tools/tests/fixtures/validate-skills/with-trigger/SKILL.md +0 -8
  367. package/tools/tests/test_validate_skills.py +0 -476
  368. package/tools/validate-published-implementation-model.mjs +0 -59
  369. package/tools/validate-sidebar-order.js +0 -388
  370. package/tools/validate-svg-changes.sh +0 -356
  371. package/tools/validate_skills.py +0 -698
  372. package/web-bundles/README.md +0 -46
  373. package/web-bundles/brainstorming-coach/INSTRUCTIONS.md +0 -86
  374. package/web-bundles/brainstorming-coach/SKILL.md +0 -83
  375. package/web-bundles/brainstorming-coach/brain-methods.csv +0 -62
  376. package/web-bundles/bundles.json +0 -139
  377. package/web-bundles/market-and-industry-research/INSTRUCTIONS.md +0 -88
  378. package/web-bundles/market-and-industry-research/SKILL.md +0 -59
  379. package/web-bundles/prd-coach/INSTRUCTIONS.md +0 -86
  380. package/web-bundles/prd-coach/SKILL.md +0 -101
  381. package/web-bundles/prd-coach/prd-template.md +0 -165
  382. package/web-bundles/prd-coach/prd-validation-checklist.md +0 -135
  383. package/web-bundles/prfaq-coach/INSTRUCTIONS.md +0 -86
  384. package/web-bundles/prfaq-coach/SKILL.md +0 -139
  385. package/web-bundles/product-brief-coach/INSTRUCTIONS.md +0 -86
  386. package/web-bundles/product-brief-coach/SKILL.md +0 -113
  387. package/web-bundles/ux-coach/INSTRUCTIONS.md +0 -92
  388. package/web-bundles/ux-coach/SKILL.md +0 -187
  389. package/web-bundles/ux-coach/ux-validation.md +0 -100
@@ -1,2289 +0,0 @@
1
- const path = require('node:path');
2
- const fs = require('../fs-native');
3
- const yaml = require('yaml');
4
- const prompts = require('../prompts');
5
- const { getProjectRoot, getSourcePath, getModulePath } = require('../project-root');
6
- const { CLIUtils } = require('../cli-utils');
7
- const { ExternalModuleManager } = require('./external-manager');
8
- const { discoverShims } = require('../core/shim-policy');
9
-
10
- class OfficialModules {
11
- constructor(options = {}) {
12
- this.externalModuleManager = new ExternalModuleManager();
13
- // Config collection state (merged from ConfigCollector)
14
- this.collectedConfig = {};
15
- this._existingConfig = null;
16
- // Tracked during interactive config collection so {directory_name}
17
- // placeholder defaults can be resolved in buildQuestion().
18
- this.currentProjectDir = null;
19
- // Install-time channel flag state. Set by Config.build once, then used as
20
- // the default for every findModuleSource/cloneExternalModule call so that
21
- // pre-install config collection and the install step agree on which ref
22
- // to clone.
23
- this.channelOptions = options.channelOptions || null;
24
- }
25
-
26
- /**
27
- * Module configurations collected during install.
28
- */
29
- get moduleConfigs() {
30
- return this.collectedConfig;
31
- }
32
-
33
- /**
34
- * Existing module configurations read from a previous installation.
35
- */
36
- get existingConfig() {
37
- return this._existingConfig;
38
- }
39
-
40
- /**
41
- * Build a configured OfficialModules instance from install config.
42
- * @param {Object} config - Clean install config (from Config.build)
43
- * @param {Object} paths - InstallPaths instance
44
- * @returns {OfficialModules}
45
- */
46
- static async build(config, paths) {
47
- const instance = new OfficialModules({ channelOptions: config.channelOptions });
48
-
49
- // Pre-collected by UI or quickUpdate — store and load existing for path-change detection
50
- if (config.moduleConfigs) {
51
- instance.collectedConfig = config.moduleConfigs;
52
- await instance.loadExistingConfig(paths.projectRoot);
53
- return instance;
54
- }
55
-
56
- // Headless collection (--yes flag from CLI without UI, tests)
57
- if (config.hasCoreConfig()) {
58
- instance.collectedConfig.core = config.coreConfig;
59
- instance.allAnswers = {};
60
- for (const [key, value] of Object.entries(config.coreConfig)) {
61
- instance.allAnswers[`core_${key}`] = value;
62
- }
63
- }
64
-
65
- const toCollect = config.hasCoreConfig() ? config.modules.filter((m) => m !== 'core') : [...config.modules];
66
-
67
- await instance.collectAllConfigurations(toCollect, paths.projectRoot, {
68
- skipPrompts: config.skipPrompts,
69
- });
70
-
71
- return instance;
72
- }
73
-
74
- /**
75
- * Copy a file to the target location
76
- * @param {string} sourcePath - Source file path
77
- * @param {string} targetPath - Target file path
78
- * @param {boolean} overwrite - Whether to overwrite existing files (default: true)
79
- */
80
- async copyFile(sourcePath, targetPath, overwrite = true) {
81
- await fs.copy(sourcePath, targetPath, { overwrite });
82
- }
83
-
84
- /**
85
- * Copy a directory recursively
86
- * @param {string} sourceDir - Source directory path
87
- * @param {string} targetDir - Target directory path
88
- * @param {boolean} overwrite - Whether to overwrite existing files (default: true)
89
- */
90
- async copyDirectory(sourceDir, targetDir, overwrite = true) {
91
- await fs.ensureDir(targetDir);
92
- const entries = await fs.readdir(sourceDir, { withFileTypes: true });
93
-
94
- for (const entry of entries) {
95
- const sourcePath = path.join(sourceDir, entry.name);
96
- const targetPath = path.join(targetDir, entry.name);
97
-
98
- if (entry.isDirectory()) {
99
- await this.copyDirectory(sourcePath, targetPath, overwrite);
100
- } else {
101
- await this.copyFile(sourcePath, targetPath, overwrite);
102
- }
103
- }
104
- }
105
-
106
- /**
107
- * List all available built-in modules (core and bmm).
108
- * All other modules come from external-official-modules.yaml
109
- * @returns {Object} Object with modules array
110
- */
111
- async listAvailable() {
112
- const modules = [];
113
-
114
- // Add built-in core module (directly under src/core-skills)
115
- const corePath = getSourcePath('core-skills');
116
- if (await fs.pathExists(corePath)) {
117
- const coreInfo = await this.getModuleInfo(corePath, 'core', 'src/core-skills');
118
- if (coreInfo) {
119
- modules.push(coreInfo);
120
- }
121
- }
122
-
123
- // Add built-in bmm module (directly under src/bmm-skills)
124
- const bmmPath = getSourcePath('bmm-skills');
125
- if (await fs.pathExists(bmmPath)) {
126
- const bmmInfo = await this.getModuleInfo(bmmPath, 'bmm', 'src/bmm-skills');
127
- if (bmmInfo) {
128
- modules.push(bmmInfo);
129
- }
130
- }
131
-
132
- return { modules };
133
- }
134
-
135
- async discoverShims(moduleNames = [], options = {}) {
136
- const shims = [];
137
-
138
- for (const moduleName of moduleNames) {
139
- const sourcePath = await this.findModuleSource(moduleName, {
140
- silent: true,
141
- channelOptions: options.channelOptions,
142
- });
143
- if (!sourcePath) continue;
144
-
145
- const moduleShims = await discoverShims(sourcePath);
146
- for (const shim of moduleShims) shims.push({ ...shim, module: moduleName });
147
- }
148
-
149
- return shims;
150
- }
151
-
152
- /**
153
- * Get module information from a module path
154
- * @param {string} modulePath - Path to the module directory
155
- * @param {string} defaultName - Default name for the module
156
- * @param {string} sourceDescription - Description of where the module was found
157
- * @returns {Object|null} Module info or null if not a valid module
158
- */
159
- async getModuleInfo(modulePath, defaultName, sourceDescription) {
160
- const moduleConfigPath = path.join(modulePath, 'module.yaml');
161
-
162
- if (!(await fs.pathExists(moduleConfigPath))) {
163
- // Check resolution cache for strategy 5 modules (no module.yaml on disk)
164
- const { CustomModuleManager } = require('./custom-module-manager');
165
- const customMgr = new CustomModuleManager();
166
- const resolved = customMgr.getResolution(defaultName);
167
- if (resolved && resolved.synthesizedModuleYaml) {
168
- return {
169
- id: resolved.code,
170
- path: modulePath,
171
- name: resolved.name,
172
- description: resolved.description,
173
- version: resolved.version || '1.0.0',
174
- source: sourceDescription,
175
- dependencies: [],
176
- defaultSelected: false,
177
- };
178
- }
179
- return null;
180
- }
181
-
182
- const moduleInfo = {
183
- id: defaultName,
184
- path: modulePath,
185
- name: defaultName
186
- .split('-')
187
- .map((word) => word.charAt(0).toUpperCase() + word.slice(1))
188
- .join(' '),
189
- description: 'BMAD Module',
190
- version: '5.0.0',
191
- source: sourceDescription,
192
- };
193
-
194
- // Read module config for metadata
195
- try {
196
- const configContent = await fs.readFile(moduleConfigPath, 'utf8');
197
- const config = yaml.parse(configContent);
198
-
199
- // Use the code property as the id if available
200
- if (config.code) {
201
- moduleInfo.id = config.code;
202
- }
203
-
204
- moduleInfo.name = config.name || moduleInfo.name;
205
- moduleInfo.description = config.description || moduleInfo.description;
206
- moduleInfo.version = config.version || moduleInfo.version;
207
- moduleInfo.dependencies = config.dependencies || [];
208
- moduleInfo.defaultSelected = config.default_selected === undefined ? false : config.default_selected;
209
- } catch (error) {
210
- await prompts.log.warn(`Failed to read config for ${defaultName}: ${error.message}`);
211
- }
212
-
213
- return moduleInfo;
214
- }
215
-
216
- /**
217
- * Find the source path for a module by searching all possible locations
218
- * @param {string} moduleCode - Code of the module to find (from module.yaml)
219
- * @returns {string|null} Path to the module source or null if not found
220
- */
221
- async findModuleSource(moduleCode, options = {}) {
222
- // Inherit channelOptions from the install-scoped instance when the caller
223
- // didn't pass one explicitly. Keeps pre-install config collection and the
224
- // actual install step looking at the same git ref.
225
- if (options.channelOptions === undefined && this.channelOptions) {
226
- options = { ...options, channelOptions: this.channelOptions };
227
- }
228
- const projectRoot = getProjectRoot();
229
-
230
- // Check for core module (directly under src/core-skills)
231
- if (moduleCode === 'core') {
232
- const corePath = getSourcePath('core-skills');
233
- if (await fs.pathExists(corePath)) {
234
- return corePath;
235
- }
236
- }
237
-
238
- // Check for built-in bmm module (directly under src/bmm-skills)
239
- if (moduleCode === 'bmm') {
240
- const bmmPath = getSourcePath('bmm-skills');
241
- if (await fs.pathExists(bmmPath)) {
242
- return bmmPath;
243
- }
244
- }
245
-
246
- // Check external official modules (pass channelOptions so channel plan applies)
247
- const externalSource = await this.externalModuleManager.findExternalModuleSource(moduleCode, options);
248
- if (externalSource) {
249
- return externalSource;
250
- }
251
-
252
- // Check custom modules (from user-provided URLs, already cloned to cache)
253
- const { CustomModuleManager } = require('./custom-module-manager');
254
- const customMgr = new CustomModuleManager();
255
- const customSource = await customMgr.findModuleSourceByCode(moduleCode, options);
256
- if (customSource) {
257
- return customSource;
258
- }
259
-
260
- return null;
261
- }
262
-
263
- /**
264
- * Install a module
265
- * @param {string} moduleName - Code of the module to install (from module.yaml)
266
- * @param {string} bmadDir - Target bmad directory
267
- * @param {Function} fileTrackingCallback - Optional callback to track installed files
268
- * @param {Object} options - Additional installation options
269
- * @param {Array<string>} options.installedIDEs - Array of IDE codes that were installed
270
- * @param {Object} options.moduleConfig - Module configuration from config collector
271
- * @param {Object} options.logger - Logger instance for output
272
- */
273
- async install(moduleName, bmadDir, fileTrackingCallback = null, options = {}) {
274
- // Check if this module has a plugin resolution (custom marketplace install)
275
- const { CustomModuleManager } = require('./custom-module-manager');
276
- const customMgr = new CustomModuleManager();
277
- const resolved = customMgr.getResolution(moduleName);
278
- if (resolved) {
279
- return this.installFromResolution(resolved, bmadDir, fileTrackingCallback, options);
280
- }
281
-
282
- const sourcePath = await this.findModuleSource(moduleName, {
283
- silent: options.silent,
284
- channelOptions: options.channelOptions,
285
- });
286
- const targetPath = path.join(bmadDir, moduleName);
287
-
288
- if (!sourcePath) {
289
- throw new Error(
290
- `Source for module '${moduleName}' is not available. It will be retained but cannot be updated without its source files.`,
291
- );
292
- }
293
-
294
- if (await fs.pathExists(targetPath)) {
295
- await fs.remove(targetPath);
296
- }
297
-
298
- // Marketplace-plugin registry modules keep their installable skills outside
299
- // the directory that holds module.yaml (sourcePath points at the -setup
300
- // skill's assets/), so they cannot be installed by copying sourcePath. Copy
301
- // the resolved skill directories instead, matching how custom marketplace
302
- // installs lay out a module. Everything else (manifest, version info) flows
303
- // through the standard external-module path below.
304
- const moduleInfo = await this.externalModuleManager.getModuleByCode(moduleName);
305
- if (moduleInfo && moduleInfo.marketplacePlugin) {
306
- const pluginResolution = this.externalModuleManager.getPluginResolution(moduleName);
307
- // Fail loud: copying sourcePath here would install only the -setup skill's
308
- // assets/ (module.yaml + module-help.csv) and none of the skills — a
309
- // silent, broken partial install. Abort instead.
310
- if (!pluginResolution || !Array.isArray(pluginResolution.skillPaths) || pluginResolution.skillPaths.length === 0) {
311
- throw new Error(
312
- `Module '${moduleName}' is registered as a marketplace plugin but its skills could not be resolved ` +
313
- `from .claude-plugin/marketplace.json (missing or malformed on the selected channel). ` +
314
- `Aborting to avoid a partial install with no skills.`,
315
- );
316
- }
317
- await this._copyResolvedSkills(pluginResolution, targetPath, fileTrackingCallback, options.moduleConfig, {
318
- installShims: options.installShims,
319
- });
320
- } else {
321
- await this.copyModuleWithFiltering(sourcePath, targetPath, fileTrackingCallback, options.moduleConfig, {
322
- installShims: options.installShims,
323
- });
324
- }
325
-
326
- if (!options.skipModuleInstaller) {
327
- await this.createModuleDirectories(moduleName, bmadDir, options);
328
- }
329
-
330
- const { Manifest } = require('../core/manifest');
331
- const manifestObj = new Manifest();
332
- const versionInfo = await manifestObj.getModuleVersionInfo(moduleName, bmadDir, sourcePath);
333
-
334
- // Pick up channel resolution recorded by the external manager (the only
335
- // manager that does pre-clone resolution now that community is retired).
336
- const resolution = this.externalModuleManager.getResolution(moduleName);
337
-
338
- await manifestObj.addModule(bmadDir, moduleName, {
339
- version: resolution?.version || versionInfo.version,
340
- source: versionInfo.source,
341
- npmPackage: versionInfo.npmPackage,
342
- repoUrl: versionInfo.repoUrl,
343
- channel: resolution?.channel,
344
- sha: resolution?.sha,
345
- });
346
-
347
- return { success: true, module: moduleName, path: targetPath, versionInfo };
348
- }
349
-
350
- /**
351
- * Lay out a PluginResolver resolution on disk: copy each resolved skill
352
- * directory (flattened by leaf name) into targetPath and place module-help.csv
353
- * at the module root. Shared by both custom marketplace installs
354
- * (installFromResolution) and official marketplace-plugin registry installs
355
- * (install), so the two paths cannot drift.
356
- * @param {Object} resolved - ResolvedModule from PluginResolver
357
- * @param {string} targetPath - Destination module directory (e.g. bmadDir/<code>)
358
- * @param {Function} fileTrackingCallback - Optional callback to track installed files
359
- * @param {Object} moduleConfig - Module configuration passed to copy filtering
360
- */
361
- async _copyResolvedSkills(resolved, targetPath, fileTrackingCallback = null, moduleConfig = {}, installOptions = {}) {
362
- await fs.ensureDir(targetPath);
363
-
364
- // Copy each skill directory, flattened by leaf name. Leaf names must be
365
- // unique — two skills that flatten to the same directory would silently
366
- // overwrite each other, so fail loud instead.
367
- const seenLeaves = new Map();
368
- for (const skillPath of resolved.skillPaths) {
369
- const skillDirName = path.basename(skillPath);
370
- if (seenLeaves.has(skillDirName)) {
371
- throw new Error(
372
- `Cannot install module '${resolved.code}': skill directories '${seenLeaves.get(skillDirName)}' and ` +
373
- `'${skillPath}' share the leaf name '${skillDirName}' and would overwrite each other. ` +
374
- `Skill directory names must be unique.`,
375
- );
376
- }
377
- seenLeaves.set(skillDirName, skillPath);
378
- const skillTarget = path.join(targetPath, skillDirName);
379
- await this.copyModuleWithFiltering(skillPath, skillTarget, fileTrackingCallback, moduleConfig, installOptions);
380
- }
381
-
382
- // Place module-help.csv at the module root.
383
- const helpTarget = path.join(targetPath, 'module-help.csv');
384
- if (resolved.moduleHelpCsvPath) {
385
- // Strategies 1-4: copy the existing file.
386
- await fs.copy(resolved.moduleHelpCsvPath, helpTarget, { overwrite: true });
387
- if (fileTrackingCallback) fileTrackingCallback(helpTarget);
388
- } else if (resolved.synthesizedHelpCsv) {
389
- // Strategy 5: write synthesized content.
390
- await fs.writeFile(helpTarget, resolved.synthesizedHelpCsv, 'utf8');
391
- if (fileTrackingCallback) fileTrackingCallback(helpTarget);
392
- }
393
- }
394
-
395
- /**
396
- * Install a module from a PluginResolver resolution result.
397
- * Copies specific skill directories and places module-help.csv at the target root.
398
- * @param {Object} resolved - ResolvedModule from PluginResolver
399
- * @param {string} bmadDir - Target bmad directory
400
- * @param {Function} fileTrackingCallback - Optional callback to track installed files
401
- * @param {Object} options - Installation options
402
- */
403
- async installFromResolution(resolved, bmadDir, fileTrackingCallback = null, options = {}) {
404
- const targetPath = path.join(bmadDir, resolved.code);
405
-
406
- if (await fs.pathExists(targetPath)) {
407
- await fs.remove(targetPath);
408
- }
409
-
410
- await this._copyResolvedSkills(resolved, targetPath, fileTrackingCallback, options.moduleConfig, {
411
- installShims: options.installShims,
412
- });
413
-
414
- // Create directories declared in module.yaml (strategies 1-4 may have these)
415
- if (!options.skipModuleInstaller) {
416
- await this.createModuleDirectories(resolved.code, bmadDir, options);
417
- }
418
-
419
- // Update manifest. For custom-source installs we derive channel from the
420
- // cloneRef (present → pinned, absent → next; local paths have no channel).
421
- const { Manifest } = require('../core/manifest');
422
- const manifestObj = new Manifest();
423
-
424
- const hasGitClone = !!resolved.repoUrl;
425
- const manifestEntry = {
426
- version: resolved.cloneRef || (hasGitClone ? 'main' : resolved.version || null),
427
- source: 'custom',
428
- npmPackage: null,
429
- repoUrl: resolved.repoUrl || null,
430
- };
431
- if (hasGitClone) {
432
- manifestEntry.channel = resolved.cloneRef ? 'pinned' : 'next';
433
- if (resolved.cloneSha) manifestEntry.sha = resolved.cloneSha;
434
- if (resolved.rawInput) manifestEntry.rawSource = resolved.rawInput;
435
- }
436
- if (resolved.localPath) manifestEntry.localPath = resolved.localPath;
437
- await manifestObj.addModule(bmadDir, resolved.code, manifestEntry);
438
-
439
- return {
440
- success: true,
441
- module: resolved.code,
442
- path: targetPath,
443
- // Mirror the manifestEntry.version precedence above so downstream summary
444
- // lines show the same string we just wrote to disk (custom git-backed
445
- // installs show the cloned ref or 'main').
446
- versionInfo: {
447
- version: resolved.cloneRef || (hasGitClone ? 'main' : resolved.version || ''),
448
- },
449
- };
450
- }
451
-
452
- /**
453
- * Update an existing module
454
- * @param {string} moduleName - Name of the module to update
455
- * @param {string} bmadDir - Target bmad directory
456
- */
457
- async update(moduleName, bmadDir) {
458
- const sourcePath = await this.findModuleSource(moduleName);
459
- const targetPath = path.join(bmadDir, moduleName);
460
-
461
- if (!sourcePath) {
462
- throw new Error(`Module '${moduleName}' not found in any source location`);
463
- }
464
-
465
- if (!(await fs.pathExists(targetPath))) {
466
- throw new Error(`Module '${moduleName}' is not installed`);
467
- }
468
-
469
- await this.syncModule(sourcePath, targetPath);
470
-
471
- return {
472
- success: true,
473
- module: moduleName,
474
- path: targetPath,
475
- };
476
- }
477
-
478
- /**
479
- * Remove a module
480
- * @param {string} moduleName - Name of the module to remove
481
- * @param {string} bmadDir - Target bmad directory
482
- */
483
- async remove(moduleName, bmadDir) {
484
- const targetPath = path.join(bmadDir, moduleName);
485
-
486
- if (!(await fs.pathExists(targetPath))) {
487
- throw new Error(`Module '${moduleName}' is not installed`);
488
- }
489
-
490
- await fs.remove(targetPath);
491
-
492
- return {
493
- success: true,
494
- module: moduleName,
495
- };
496
- }
497
-
498
- /**
499
- * Check if a module is installed
500
- * @param {string} moduleName - Name of the module
501
- * @param {string} bmadDir - Target bmad directory
502
- * @returns {boolean} True if module is installed
503
- */
504
- async isInstalled(moduleName, bmadDir) {
505
- const targetPath = path.join(bmadDir, moduleName);
506
- return await fs.pathExists(targetPath);
507
- }
508
-
509
- /**
510
- * Get installed module info
511
- * @param {string} moduleName - Name of the module
512
- * @param {string} bmadDir - Target bmad directory
513
- * @returns {Object|null} Module info or null if not installed
514
- */
515
- async getInstalledInfo(moduleName, bmadDir) {
516
- const targetPath = path.join(bmadDir, moduleName);
517
-
518
- if (!(await fs.pathExists(targetPath))) {
519
- return null;
520
- }
521
-
522
- const configPath = path.join(targetPath, 'config.yaml');
523
- const moduleInfo = {
524
- id: moduleName,
525
- path: targetPath,
526
- installed: true,
527
- };
528
-
529
- if (await fs.pathExists(configPath)) {
530
- try {
531
- const configContent = await fs.readFile(configPath, 'utf8');
532
- const config = yaml.parse(configContent);
533
- Object.assign(moduleInfo, config);
534
- } catch (error) {
535
- await prompts.log.warn(`Failed to read installed module config: ${error.message}`);
536
- }
537
- }
538
-
539
- return moduleInfo;
540
- }
541
-
542
- /**
543
- * Copy module with filtering for localskip agents and conditional content
544
- * @param {string} sourcePath - Source module path
545
- * @param {string} targetPath - Target module path
546
- * @param {Function} fileTrackingCallback - Optional callback to track installed files
547
- * @param {Object} moduleConfig - Module configuration with conditional flags
548
- */
549
- async copyModuleWithFiltering(sourcePath, targetPath, fileTrackingCallback = null, moduleConfig = {}, installOptions = {}) {
550
- // Get all files in source
551
- const sourceFiles = await this.getFileList(sourcePath);
552
- const shimDirectories =
553
- installOptions.installShims === false
554
- ? (await discoverShims(sourcePath)).map((shim) => shim.relativeDirectory.split(path.sep).join('/'))
555
- : [];
556
-
557
- for (const file of sourceFiles) {
558
- const normalizedFile = file.split(path.sep).join('/');
559
- if (shimDirectories.some((shimDir) => shimDir === '' || normalizedFile === shimDir || normalizedFile.startsWith(`${shimDir}/`))) {
560
- continue;
561
- }
562
- // Skip sub-modules directory - these are IDE-specific and handled separately
563
- if (file.startsWith('sub-modules/')) {
564
- continue;
565
- }
566
-
567
- // Skip sidecar directories - these contain agent-specific assets not needed at install time
568
- const isInSidecarDirectory = path
569
- .dirname(file)
570
- .split('/')
571
- .some((dir) => dir.toLowerCase().endsWith('-sidecar'));
572
-
573
- if (isInSidecarDirectory) {
574
- continue;
575
- }
576
-
577
- // Skip module.yaml at root - it's only needed at install time
578
- if (file === 'module.yaml') {
579
- continue;
580
- }
581
-
582
- // Skip module root config.yaml only - generated by config collector with actual values
583
- // Workflow-level config.yaml (e.g. workflows/orchestrate-story/config.yaml) must be copied
584
- // for custom modules that use workflow-specific configuration
585
- if (file === 'config.yaml') {
586
- continue;
587
- }
588
-
589
- const sourceFile = path.join(sourcePath, file);
590
- const targetFile = path.join(targetPath, file);
591
-
592
- // Check if this is an agent file
593
- if (file.startsWith('agents/') && file.endsWith('.md')) {
594
- // Read the file to check for localskip
595
- const content = await fs.readFile(sourceFile, 'utf8');
596
-
597
- // Check for localskip="true" in the agent tag
598
- const agentMatch = content.match(/<agent[^>]*\slocalskip="true"[^>]*>/);
599
- if (agentMatch) {
600
- await prompts.log.message(` Skipping web-only agent: ${path.basename(file)}`);
601
- continue; // Skip this agent
602
- }
603
- }
604
-
605
- // Copy the file with placeholder replacement
606
- await this.copyFile(sourceFile, targetFile);
607
-
608
- // Track the file if callback provided
609
- if (fileTrackingCallback) {
610
- fileTrackingCallback(targetFile);
611
- }
612
- }
613
- }
614
-
615
- /**
616
- * Create directories declared in module.yaml's `directories` key
617
- * This replaces the security-risky module installer pattern with declarative config
618
- * During updates, if a directory path changed, moves the old directory to the new path
619
- * @param {string} moduleName - Name of the module
620
- * @param {string} bmadDir - Target bmad directory
621
- * @param {Object} options - Installation options
622
- * @param {Object} options.moduleConfig - Module configuration from config collector
623
- * @param {Object} options.existingModuleConfig - Previous module config (for detecting path changes during updates)
624
- * @param {Object} options.coreConfig - Core configuration
625
- * @returns {Promise<{createdDirs: string[], movedDirs: string[], createdWdsFolders: string[]}>} Created directories info
626
- */
627
- async createModuleDirectories(moduleName, bmadDir, options = {}) {
628
- const moduleConfig = options.moduleConfig || {};
629
- const existingModuleConfig = options.existingModuleConfig || {};
630
- const projectRoot = path.dirname(bmadDir);
631
- const emptyResult = { createdDirs: [], movedDirs: [], createdWdsFolders: [] };
632
-
633
- // Special handling for core module - it's in src/core-skills not src/modules
634
- let sourcePath;
635
- if (moduleName === 'core') {
636
- sourcePath = getSourcePath('core-skills');
637
- } else {
638
- sourcePath = await this.findModuleSource(moduleName, { silent: true });
639
- if (!sourcePath) {
640
- return emptyResult; // No source found, skip
641
- }
642
- }
643
-
644
- // Read module.yaml to find the `directories` key
645
- const moduleYamlPath = path.join(sourcePath, 'module.yaml');
646
- if (!(await fs.pathExists(moduleYamlPath))) {
647
- return emptyResult; // No module.yaml, skip
648
- }
649
-
650
- let moduleYaml;
651
- try {
652
- const yamlContent = await fs.readFile(moduleYamlPath, 'utf8');
653
- moduleYaml = yaml.parse(yamlContent);
654
- } catch (error) {
655
- await prompts.log.warn(`Invalid module.yaml for ${moduleName}: ${error.message}`);
656
- return emptyResult;
657
- }
658
-
659
- if (!moduleYaml || !moduleYaml.directories) {
660
- return emptyResult; // No directories declared, skip
661
- }
662
-
663
- const directories = moduleYaml.directories;
664
- const wdsFolders = moduleYaml.wds_folders || [];
665
- const createdDirs = [];
666
- const movedDirs = [];
667
- const createdWdsFolders = [];
668
-
669
- for (const dirRef of directories) {
670
- // Parse variable reference like "{design_artifacts}"
671
- const varMatch = dirRef.match(/^\{([^}]+)\}$/);
672
- if (!varMatch) {
673
- // Not a variable reference, skip
674
- continue;
675
- }
676
-
677
- const configKey = varMatch[1];
678
- const dirValue = moduleConfig[configKey];
679
- if (!dirValue || typeof dirValue !== 'string') {
680
- continue; // No value or not a string, skip
681
- }
682
-
683
- // Strip {project-root}/ prefix if present
684
- let dirPath = dirValue.replace(/^\{project-root\}\/?/, '');
685
-
686
- // Handle remaining {project-root} anywhere in the path
687
- dirPath = dirPath.replaceAll('{project-root}', '');
688
-
689
- // Resolve to absolute path
690
- const fullPath = path.join(projectRoot, dirPath);
691
-
692
- // Validate path is within project root (prevent directory traversal)
693
- const normalizedPath = path.normalize(fullPath);
694
- const normalizedRoot = path.normalize(projectRoot);
695
- if (!normalizedPath.startsWith(normalizedRoot + path.sep) && normalizedPath !== normalizedRoot) {
696
- const color = await prompts.getColor();
697
- await prompts.log.warn(color.yellow(`${configKey} path escapes project root, skipping: ${dirPath}`));
698
- continue;
699
- }
700
-
701
- // Check if directory path changed from previous config (update/modify scenario)
702
- const oldDirValue = existingModuleConfig[configKey];
703
- let oldFullPath = null;
704
- let oldDirPath = null;
705
- if (oldDirValue && typeof oldDirValue === 'string') {
706
- // F3: Normalize both values before comparing to avoid false negatives
707
- // from trailing slashes, separator differences, or prefix format variations
708
- let normalizedOld = oldDirValue.replace(/^\{project-root\}\/?/, '');
709
- normalizedOld = path.normalize(normalizedOld.replaceAll('{project-root}', ''));
710
- const normalizedNew = path.normalize(dirPath);
711
-
712
- if (normalizedOld !== normalizedNew) {
713
- oldDirPath = normalizedOld;
714
- oldFullPath = path.join(projectRoot, oldDirPath);
715
- const normalizedOldAbsolute = path.normalize(oldFullPath);
716
- if (!normalizedOldAbsolute.startsWith(normalizedRoot + path.sep) && normalizedOldAbsolute !== normalizedRoot) {
717
- oldFullPath = null; // Old path escapes project root, ignore it
718
- }
719
-
720
- // F13: Prevent parent/child move (e.g. docs/planning → docs/planning/v2)
721
- if (oldFullPath) {
722
- const normalizedNewAbsolute = path.normalize(fullPath);
723
- if (
724
- normalizedOldAbsolute.startsWith(normalizedNewAbsolute + path.sep) ||
725
- normalizedNewAbsolute.startsWith(normalizedOldAbsolute + path.sep)
726
- ) {
727
- const color = await prompts.getColor();
728
- await prompts.log.warn(
729
- color.yellow(
730
- `${configKey}: cannot move between parent/child paths (${oldDirPath} / ${dirPath}), creating new directory instead`,
731
- ),
732
- );
733
- oldFullPath = null;
734
- }
735
- }
736
- }
737
- }
738
-
739
- const dirName = configKey.replaceAll('_', ' ');
740
-
741
- if (oldFullPath && (await fs.pathExists(oldFullPath)) && !(await fs.pathExists(fullPath))) {
742
- // Path changed and old dir exists → move old to new location
743
- // F1: Use fs.move() instead of fs.rename() for cross-device/volume support
744
- // F2: Wrap in try/catch — fallback to creating new dir on failure
745
- try {
746
- await fs.ensureDir(path.dirname(fullPath));
747
- await fs.move(oldFullPath, fullPath);
748
- movedDirs.push(`${dirName}: ${oldDirPath} → ${dirPath}`);
749
- } catch (moveError) {
750
- const color = await prompts.getColor();
751
- await prompts.log.warn(
752
- color.yellow(
753
- `Failed to move ${oldDirPath} → ${dirPath}: ${moveError.message}\n Creating new directory instead. Please move contents from the old directory manually.`,
754
- ),
755
- );
756
- await fs.ensureDir(fullPath);
757
- createdDirs.push(`${dirName}: ${dirPath}`);
758
- }
759
- } else if (oldFullPath && (await fs.pathExists(oldFullPath)) && (await fs.pathExists(fullPath))) {
760
- // F5: Both old and new directories exist — warn user about potential orphaned documents
761
- const color = await prompts.getColor();
762
- await prompts.log.warn(
763
- color.yellow(
764
- `${dirName}: path changed but both directories exist:\n Old: ${oldDirPath}\n New: ${dirPath}\n Old directory may contain orphaned documents — please review and merge manually.`,
765
- ),
766
- );
767
- } else if (!(await fs.pathExists(fullPath))) {
768
- // New directory doesn't exist yet → create it
769
- createdDirs.push(`${dirName}: ${dirPath}`);
770
- await fs.ensureDir(fullPath);
771
- }
772
-
773
- // Create WDS subfolders if this is the design_artifacts directory
774
- if (configKey === 'design_artifacts' && wdsFolders.length > 0) {
775
- for (const subfolder of wdsFolders) {
776
- const subPath = path.join(fullPath, subfolder);
777
- if (!(await fs.pathExists(subPath))) {
778
- await fs.ensureDir(subPath);
779
- createdWdsFolders.push(subfolder);
780
- }
781
- }
782
- }
783
- }
784
-
785
- return { createdDirs, movedDirs, createdWdsFolders };
786
- }
787
-
788
- /**
789
- * Private: Sync module files (preserving user modifications)
790
- * @param {string} sourcePath - Source module path
791
- * @param {string} targetPath - Target module path
792
- */
793
- async syncModule(sourcePath, targetPath) {
794
- // Get list of all source files
795
- const sourceFiles = await this.getFileList(sourcePath);
796
-
797
- for (const file of sourceFiles) {
798
- const sourceFile = path.join(sourcePath, file);
799
- const targetFile = path.join(targetPath, file);
800
-
801
- // Check if target file exists and has been modified
802
- if (await fs.pathExists(targetFile)) {
803
- const sourceStats = await fs.stat(sourceFile);
804
- const targetStats = await fs.stat(targetFile);
805
-
806
- // Skip if target is newer (user modified)
807
- if (targetStats.mtime > sourceStats.mtime) {
808
- continue;
809
- }
810
- }
811
-
812
- // Copy file with placeholder replacement
813
- await this.copyFile(sourceFile, targetFile);
814
- }
815
- }
816
-
817
- /**
818
- * Private: Get list of all files in a directory
819
- * @param {string} dir - Directory path
820
- * @param {string} baseDir - Base directory for relative paths
821
- * @returns {Array} List of relative file paths
822
- */
823
- async getFileList(dir, baseDir = dir) {
824
- const files = [];
825
- const entries = await fs.readdir(dir, { withFileTypes: true });
826
-
827
- for (const entry of entries) {
828
- const fullPath = path.join(dir, entry.name);
829
-
830
- if (entry.isDirectory()) {
831
- const subFiles = await this.getFileList(fullPath, baseDir);
832
- files.push(...subFiles);
833
- } else {
834
- files.push(path.relative(baseDir, fullPath));
835
- }
836
- }
837
-
838
- return files;
839
- }
840
-
841
- // ─── Config collection methods (merged from ConfigCollector) ───
842
-
843
- /**
844
- * Find the bmad installation directory in a project
845
- * V6+ installations can use ANY folder name but ALWAYS have _config/manifest.yaml
846
- * @param {string} projectDir - Project directory
847
- * @returns {Promise<string>} Path to bmad directory
848
- */
849
- async findBmadDir(projectDir) {
850
- // Check if project directory exists
851
- if (!(await fs.pathExists(projectDir))) {
852
- // Project doesn't exist yet, return default
853
- return path.join(projectDir, 'bmad');
854
- }
855
-
856
- // V6+ strategy: Look for ANY directory with _config/manifest.yaml
857
- // This is the definitive marker of a V6+ installation
858
- try {
859
- const entries = await fs.readdir(projectDir, { withFileTypes: true });
860
- for (const entry of entries) {
861
- if (entry.isDirectory()) {
862
- const manifestPath = path.join(projectDir, entry.name, '_config', 'manifest.yaml');
863
- if (await fs.pathExists(manifestPath)) {
864
- // Found a V6+ installation
865
- return path.join(projectDir, entry.name);
866
- }
867
- }
868
- }
869
- } catch {
870
- // Ignore errors, fall through to default
871
- }
872
-
873
- // No V6+ installation found, return default
874
- // This will be used for new installations
875
- return path.join(projectDir, 'bmad');
876
- }
877
-
878
- /**
879
- * Detect the existing BMAD folder name in a project
880
- * @param {string} projectDir - Project directory
881
- * @returns {Promise<string|null>} Folder name (just the name, not full path) or null if not found
882
- */
883
- async detectExistingBmadFolder(projectDir) {
884
- // Check if project directory exists
885
- if (!(await fs.pathExists(projectDir))) {
886
- return null;
887
- }
888
-
889
- // Look for ANY directory with _config/manifest.yaml
890
- try {
891
- const entries = await fs.readdir(projectDir, { withFileTypes: true });
892
- for (const entry of entries) {
893
- if (entry.isDirectory()) {
894
- const manifestPath = path.join(projectDir, entry.name, '_config', 'manifest.yaml');
895
- if (await fs.pathExists(manifestPath)) {
896
- // Found a V6+ installation, return just the folder name
897
- return entry.name;
898
- }
899
- }
900
- }
901
- } catch {
902
- // Ignore errors
903
- }
904
-
905
- return null;
906
- }
907
-
908
- /**
909
- * Load existing config if it exists from module config files
910
- * @param {string} projectDir - Target project directory
911
- */
912
- async loadExistingConfig(projectDir) {
913
- this._existingConfig = {};
914
-
915
- // Check if project directory exists first
916
- if (!(await fs.pathExists(projectDir))) {
917
- return false;
918
- }
919
-
920
- // Find the actual bmad directory (handles custom folder names)
921
- const bmadDir = await this.findBmadDir(projectDir);
922
-
923
- // Check if bmad directory exists
924
- if (!(await fs.pathExists(bmadDir))) {
925
- return false;
926
- }
927
-
928
- // Primary source: installer-written config.toml + config.user.toml (v6+).
929
- // Both files together hold all install answers; config.user.toml carries
930
- // user-scoped keys like user_name that would otherwise be re-prompted on
931
- // every reinstall.
932
- let foundAny = false;
933
- for (const fileName of ['config.toml', 'config.user.toml']) {
934
- const tomlPath = path.join(bmadDir, fileName);
935
- if (!(await fs.pathExists(tomlPath))) continue;
936
- try {
937
- const content = await fs.readFile(tomlPath, 'utf8');
938
- const parsed = parseCentralToml(content);
939
- for (const [section, values] of Object.entries(parsed)) {
940
- if (values && typeof values === 'object' && !Array.isArray(values)) {
941
- if (!this._existingConfig[section]) this._existingConfig[section] = {};
942
- Object.assign(this._existingConfig[section], values);
943
- foundAny = true;
944
- }
945
- }
946
- } catch {
947
- // Ignore parse errors
948
- }
949
- }
950
-
951
- if (foundAny) {
952
- return true;
953
- }
954
-
955
- // Fallback: legacy per-module config.yaml files (pre-v6 installations).
956
- const entries = await fs.readdir(bmadDir, { withFileTypes: true });
957
- const nonModuleDirs = new Set(['_config', '_memory', 'memory', 'docs', 'scripts', 'custom', 'render']);
958
- for (const entry of entries) {
959
- if (entry.isDirectory()) {
960
- if (nonModuleDirs.has(entry.name)) {
961
- continue;
962
- }
963
-
964
- const moduleConfigPath = path.join(bmadDir, entry.name, 'config.yaml');
965
-
966
- if (await fs.pathExists(moduleConfigPath)) {
967
- try {
968
- const content = await fs.readFile(moduleConfigPath, 'utf8');
969
- const moduleConfig = yaml.parse(content);
970
- // Only keep plain object parses. A corrupt config.yaml that parses
971
- // to a scalar or array would crash later code that does `key in cfg`
972
- // / `Object.keys(cfg)`; treat it the same as a parse error.
973
- if (moduleConfig && typeof moduleConfig === 'object' && !Array.isArray(moduleConfig)) {
974
- this._existingConfig[entry.name] = moduleConfig;
975
- foundAny = true;
976
- }
977
- } catch {
978
- // Ignore parse errors for individual modules
979
- }
980
- }
981
- }
982
- }
983
-
984
- if (foundAny) {
985
- await this._hoistCoreKeysFromLegacyModuleConfigs();
986
- }
987
-
988
- return foundAny;
989
- }
990
-
991
- /**
992
- * Migrate prior answers when a key has moved from a non-core module to core
993
- * (e.g. project_name moving from bmm to core in #2279). Without this, the
994
- * partition logic in writeCentralConfig drops the value from the bmm bucket
995
- * (because it's now a core key) without re-homing it under [core], so the
996
- * user's prior answer silently disappears on the next install/quick-update.
997
- */
998
- async _hoistCoreKeysFromLegacyModuleConfigs() {
999
- const coreSchemaPath = path.join(getSourcePath(), 'core-skills', 'module.yaml');
1000
- if (!(await fs.pathExists(coreSchemaPath))) return;
1001
-
1002
- let coreSchema;
1003
- try {
1004
- coreSchema = yaml.parse(await fs.readFile(coreSchemaPath, 'utf8'));
1005
- } catch {
1006
- return;
1007
- }
1008
- if (!coreSchema || typeof coreSchema !== 'object') return;
1009
-
1010
- const coreKeys = new Set(
1011
- Object.entries(coreSchema)
1012
- .filter(([, v]) => v && typeof v === 'object' && 'prompt' in v)
1013
- .map(([k]) => k),
1014
- );
1015
- if (coreKeys.size === 0) return;
1016
-
1017
- // Belt-and-suspenders: loadExistingConfig already filters non-object parses,
1018
- // but anyone calling _hoistCoreKeysFromLegacyModuleConfigs in isolation (or
1019
- // future code paths populating _existingConfig directly) shouldn't be able
1020
- // to crash this with a scalar / array.
1021
- const existingCore = this._existingConfig.core;
1022
- this._existingConfig.core = existingCore && typeof existingCore === 'object' && !Array.isArray(existingCore) ? existingCore : {};
1023
-
1024
- for (const [moduleName, cfg] of Object.entries(this._existingConfig)) {
1025
- if (moduleName === 'core' || !cfg || typeof cfg !== 'object' || Array.isArray(cfg)) continue;
1026
- for (const key of Object.keys(cfg)) {
1027
- if (!coreKeys.has(key)) continue;
1028
- if (!(key in this._existingConfig.core)) {
1029
- this._existingConfig.core[key] = cfg[key];
1030
- }
1031
- delete cfg[key];
1032
- }
1033
- }
1034
- }
1035
-
1036
- /**
1037
- * Pre-scan module schemas to gather metadata for the configuration gateway prompt.
1038
- * Returns info about which modules have configurable options.
1039
- * @param {Array} modules - List of non-core module names
1040
- * @returns {Promise<Array>} Array of {moduleName, displayName, questionCount, hasFieldsWithoutDefaults}
1041
- */
1042
- async scanModuleSchemas(modules) {
1043
- const metadataFields = new Set(['code', 'name', 'header', 'subheader', 'default_selected']);
1044
- const results = [];
1045
-
1046
- for (const moduleName of modules) {
1047
- // Resolve module.yaml path - standard location first, then OfficialModules search
1048
- let moduleConfigPath = null;
1049
- const standardPath = path.join(getModulePath(moduleName), 'module.yaml');
1050
- if (await fs.pathExists(standardPath)) {
1051
- moduleConfigPath = standardPath;
1052
- } else {
1053
- const moduleSourcePath = await this.findModuleSource(moduleName, { silent: true });
1054
- if (moduleSourcePath) {
1055
- moduleConfigPath = path.join(moduleSourcePath, 'module.yaml');
1056
- }
1057
- }
1058
-
1059
- if (!moduleConfigPath || !(await fs.pathExists(moduleConfigPath))) {
1060
- continue;
1061
- }
1062
-
1063
- try {
1064
- const content = await fs.readFile(moduleConfigPath, 'utf8');
1065
- const moduleConfig = yaml.parse(content);
1066
- if (!moduleConfig) continue;
1067
-
1068
- const displayName = moduleConfig.header || `${moduleName.toUpperCase()} Module`;
1069
- const configKeys = Object.keys(moduleConfig).filter((key) => key !== 'prompt');
1070
- const questionKeys = configKeys.filter((key) => {
1071
- if (metadataFields.has(key)) return false;
1072
- const item = moduleConfig[key];
1073
- return item && typeof item === 'object' && item.prompt;
1074
- });
1075
-
1076
- const hasFieldsWithoutDefaults = questionKeys.some((key) => {
1077
- const item = moduleConfig[key];
1078
- return item.default === undefined || item.default === null || item.default === '';
1079
- });
1080
-
1081
- results.push({
1082
- moduleName,
1083
- displayName,
1084
- questionCount: questionKeys.length,
1085
- hasFieldsWithoutDefaults,
1086
- });
1087
- } catch (error) {
1088
- await prompts.log.warn(`Could not read schema for module "${moduleName}": ${error.message}`);
1089
- }
1090
- }
1091
-
1092
- return results;
1093
- }
1094
-
1095
- /**
1096
- * Collect configuration for all modules
1097
- * @param {Array} modules - List of modules to configure (including 'core')
1098
- * @param {string} projectDir - Target project directory
1099
- * @param {Object} options - Additional options
1100
- * @param {boolean} options.skipPrompts - Skip prompts and use defaults (for --yes flag)
1101
- */
1102
- async collectAllConfigurations(modules, projectDir, options = {}) {
1103
- this.skipPrompts = options.skipPrompts || false;
1104
- this.modulesToCustomize = undefined;
1105
- await this.loadExistingConfig(projectDir);
1106
-
1107
- // Check if core was already collected (e.g., in early collection phase)
1108
- const coreAlreadyCollected = this.collectedConfig.core && Object.keys(this.collectedConfig.core).length > 0;
1109
-
1110
- // If core wasn't already collected, include it
1111
- const allModules = coreAlreadyCollected ? modules.filter((m) => m !== 'core') : ['core', ...modules.filter((m) => m !== 'core')];
1112
-
1113
- // Store all answers across modules for cross-referencing
1114
- if (!this.allAnswers) {
1115
- this.allAnswers = {};
1116
- }
1117
-
1118
- // Split processing: core first, then gateway, then remaining modules
1119
- const coreModules = allModules.filter((m) => m === 'core');
1120
- const nonCoreModules = allModules.filter((m) => m !== 'core');
1121
-
1122
- // Collect core config first (always fully prompted)
1123
- for (const moduleName of coreModules) {
1124
- await this.collectModuleConfig(moduleName, projectDir);
1125
- }
1126
-
1127
- // Show batch configuration gateway for non-core modules
1128
- // Scan all non-core module schemas for display names and config metadata
1129
- let scannedModules = [];
1130
- if (!this.skipPrompts && nonCoreModules.length > 0) {
1131
- scannedModules = await this.scanModuleSchemas(nonCoreModules);
1132
- const customizableModules = scannedModules.filter((m) => m.questionCount > 0);
1133
-
1134
- if (customizableModules.length > 0) {
1135
- const configMode = await prompts.select({
1136
- message: 'Module configuration',
1137
- choices: [
1138
- { name: 'Express Setup', value: 'express', hint: 'accept all defaults (recommended)' },
1139
- { name: 'Customize', value: 'customize', hint: 'choose modules to configure' },
1140
- ],
1141
- default: 'express',
1142
- });
1143
-
1144
- if (configMode === 'customize') {
1145
- const choices = customizableModules.map((m) => ({
1146
- name: `${m.displayName} (${m.questionCount} option${m.questionCount === 1 ? '' : 's'})`,
1147
- value: m.moduleName,
1148
- hint: m.hasFieldsWithoutDefaults ? 'has fields without defaults' : undefined,
1149
- checked: m.hasFieldsWithoutDefaults,
1150
- }));
1151
- const selected = await prompts.multiselect({
1152
- message: 'Select modules to customize:',
1153
- choices,
1154
- required: false,
1155
- });
1156
- this.modulesToCustomize = new Set(selected);
1157
- } else {
1158
- // Express mode: no modules to customize
1159
- this.modulesToCustomize = new Set();
1160
- }
1161
- } else {
1162
- // All non-core modules have zero config - no gateway needed
1163
- this.modulesToCustomize = new Set();
1164
- }
1165
- }
1166
-
1167
- // Collect remaining non-core modules
1168
- if (this.modulesToCustomize === undefined) {
1169
- // No gateway was shown (skipPrompts, no non-core modules, or direct call) - process all normally
1170
- for (const moduleName of nonCoreModules) {
1171
- await this.collectModuleConfig(moduleName, projectDir);
1172
- }
1173
- } else {
1174
- // Split into default modules (tasks progress) and customized modules (interactive)
1175
- const defaultModules = nonCoreModules.filter((m) => !this.modulesToCustomize.has(m));
1176
- const customizeModules = nonCoreModules.filter((m) => this.modulesToCustomize.has(m));
1177
-
1178
- // Run default modules with a single spinner
1179
- if (defaultModules.length > 0) {
1180
- // Build display name map from all scanned modules for pre-call spinner messages
1181
- const displayNameMap = new Map();
1182
- for (const m of scannedModules) {
1183
- displayNameMap.set(m.moduleName, m.displayName);
1184
- }
1185
-
1186
- const configSpinner = await prompts.spinner();
1187
- configSpinner.start('Configuring modules...');
1188
- try {
1189
- for (const moduleName of defaultModules) {
1190
- const displayName = displayNameMap.get(moduleName) || moduleName.toUpperCase();
1191
- configSpinner.message(`Configuring ${displayName}...`);
1192
- try {
1193
- this._silentConfig = true;
1194
- await this.collectModuleConfig(moduleName, projectDir);
1195
- } finally {
1196
- this._silentConfig = false;
1197
- }
1198
- }
1199
- } finally {
1200
- configSpinner.stop(customizeModules.length > 0 ? 'Module defaults applied' : 'Module configuration complete');
1201
- }
1202
- }
1203
-
1204
- // Run customized modules individually (may show interactive prompts)
1205
- for (const moduleName of customizeModules) {
1206
- await this.collectModuleConfig(moduleName, projectDir);
1207
- }
1208
-
1209
- if (customizeModules.length > 0) {
1210
- await prompts.log.step('Module configuration complete');
1211
- }
1212
- }
1213
-
1214
- // Add metadata
1215
- this.collectedConfig._meta = {
1216
- version: require(path.join(getProjectRoot(), 'package.json')).version,
1217
- installDate: new Date().toISOString(),
1218
- lastModified: new Date().toISOString(),
1219
- };
1220
-
1221
- return this.collectedConfig;
1222
- }
1223
-
1224
- /**
1225
- * Collect configuration for a single module (Quick Update mode - only new fields)
1226
- * @param {string} moduleName - Module name
1227
- * @param {string} projectDir - Target project directory
1228
- * @param {boolean} silentMode - If true, only prompt for new/missing fields
1229
- * @returns {boolean} True if new fields were prompted, false if all fields existed
1230
- */
1231
- async collectModuleConfigQuick(moduleName, projectDir, silentMode = true) {
1232
- this.currentProjectDir = projectDir;
1233
- // Load existing config if not already loaded
1234
- if (!this._existingConfig) {
1235
- await this.loadExistingConfig(projectDir);
1236
- }
1237
-
1238
- // Initialize allAnswers if not already initialized
1239
- if (!this.allAnswers) {
1240
- this.allAnswers = {};
1241
- }
1242
-
1243
- // Load module's config schema from module.yaml
1244
- // First, try the standard src/modules location
1245
- let moduleConfigPath = path.join(getModulePath(moduleName), 'module.yaml');
1246
-
1247
- // If not found in src/modules, we need to find it by searching the project
1248
- if (!(await fs.pathExists(moduleConfigPath))) {
1249
- const moduleSourcePath = await this.findModuleSource(moduleName, { silent: true });
1250
-
1251
- if (moduleSourcePath) {
1252
- moduleConfigPath = path.join(moduleSourcePath, 'module.yaml');
1253
- }
1254
- }
1255
-
1256
- if (!(await fs.pathExists(moduleConfigPath))) {
1257
- // No config schema for this module - use existing values
1258
- if (this._existingConfig && this._existingConfig[moduleName]) {
1259
- if (!this.collectedConfig[moduleName]) {
1260
- this.collectedConfig[moduleName] = {};
1261
- }
1262
- this.collectedConfig[moduleName] = { ...this._existingConfig[moduleName] };
1263
- }
1264
- return false;
1265
- }
1266
-
1267
- const configContent = await fs.readFile(moduleConfigPath, 'utf8');
1268
- const moduleConfig = yaml.parse(configContent);
1269
-
1270
- if (!moduleConfig) {
1271
- return false;
1272
- }
1273
-
1274
- // Compare schema with existing config to find new/missing fields
1275
- const configKeys = Object.keys(moduleConfig).filter((key) => key !== 'prompt');
1276
- const existingKeys = this._existingConfig && this._existingConfig[moduleName] ? Object.keys(this._existingConfig[moduleName]) : [];
1277
-
1278
- // Check if this module has no configuration keys at all (like CIS)
1279
- // Filter out metadata fields and only count actual config objects
1280
- const metadataFields = new Set(['code', 'name', 'header', 'subheader', 'default_selected']);
1281
- const actualConfigKeys = configKeys.filter((key) => !metadataFields.has(key));
1282
- const hasNoConfig = actualConfigKeys.length === 0;
1283
-
1284
- // If module has no config keys at all, handle it specially
1285
- if (hasNoConfig && moduleConfig.subheader) {
1286
- const moduleDisplayName = moduleConfig.header || `${moduleName.toUpperCase()} Module`;
1287
- await prompts.log.step(moduleDisplayName);
1288
- await prompts.log.message(` \u2713 ${moduleConfig.subheader}`);
1289
- return false; // No new fields
1290
- }
1291
-
1292
- // Find new interactive fields (with prompt)
1293
- const newKeys = configKeys.filter((key) => {
1294
- const item = moduleConfig[key];
1295
- // Check if it's a config item and doesn't exist in existing config
1296
- return item && typeof item === 'object' && item.prompt && !existingKeys.includes(key);
1297
- });
1298
-
1299
- // Find new static fields (without prompt, just result)
1300
- const newStaticKeys = configKeys.filter((key) => {
1301
- const item = moduleConfig[key];
1302
- return item && typeof item === 'object' && !item.prompt && item.result && !existingKeys.includes(key);
1303
- });
1304
-
1305
- // If in silent mode and no new keys (neither interactive nor static), use existing config and skip prompts
1306
- if (silentMode && newKeys.length === 0 && newStaticKeys.length === 0) {
1307
- if (this._existingConfig && this._existingConfig[moduleName]) {
1308
- if (!this.collectedConfig[moduleName]) {
1309
- this.collectedConfig[moduleName] = {};
1310
- }
1311
- this.collectedConfig[moduleName] = { ...this._existingConfig[moduleName] };
1312
-
1313
- // Special handling for user_name: ensure it has a value
1314
- if (
1315
- moduleName === 'core' &&
1316
- (!this.collectedConfig[moduleName].user_name || this.collectedConfig[moduleName].user_name === '[USER_NAME]')
1317
- ) {
1318
- this.collectedConfig[moduleName].user_name = this.getDefaultUsername();
1319
- }
1320
-
1321
- // Also populate allAnswers for cross-referencing
1322
- for (const [key, value] of Object.entries(this._existingConfig[moduleName])) {
1323
- // Ensure user_name is properly set in allAnswers too
1324
- let finalValue = value;
1325
- if (moduleName === 'core' && key === 'user_name' && (!value || value === '[USER_NAME]')) {
1326
- finalValue = this.getDefaultUsername();
1327
- }
1328
- this.allAnswers[`${moduleName}_${key}`] = finalValue;
1329
- }
1330
- } else if (moduleName === 'core') {
1331
- // No existing core config - ensure we at least have user_name
1332
- if (!this.collectedConfig[moduleName]) {
1333
- this.collectedConfig[moduleName] = {};
1334
- }
1335
- if (!this.collectedConfig[moduleName].user_name) {
1336
- this.collectedConfig[moduleName].user_name = this.getDefaultUsername();
1337
- this.allAnswers[`${moduleName}_user_name`] = this.getDefaultUsername();
1338
- }
1339
- }
1340
-
1341
- // Show "no config" message for modules with no new questions (that have config keys)
1342
- await prompts.log.message(` \u2713 ${moduleName.toUpperCase()} module already up to date`);
1343
- return false; // No new fields
1344
- }
1345
-
1346
- // If we have new fields (interactive or static), process them
1347
- if (newKeys.length > 0 || newStaticKeys.length > 0) {
1348
- const questions = [];
1349
- const staticAnswers = {};
1350
-
1351
- // Build questions for interactive fields
1352
- for (const key of newKeys) {
1353
- const item = moduleConfig[key];
1354
- const question = await this.buildQuestion(moduleName, key, item, moduleConfig);
1355
- if (question) {
1356
- questions.push(question);
1357
- }
1358
- }
1359
-
1360
- // Prepare static answers (no prompt, just result)
1361
- for (const key of newStaticKeys) {
1362
- staticAnswers[`${moduleName}_${key}`] = undefined;
1363
- }
1364
-
1365
- // Collect all answers (static + prompted)
1366
- let allAnswers = { ...staticAnswers };
1367
-
1368
- if (questions.length > 0 && silentMode) {
1369
- // In silent mode (quick update), use defaults for new fields instead of prompting
1370
- for (const q of questions) {
1371
- allAnswers[q.name] = typeof q.default === 'function' ? q.default({}) : q.default;
1372
- }
1373
- await prompts.log.message(` \u2713 ${moduleName.toUpperCase()} module configured with defaults`);
1374
- } else if (questions.length > 0) {
1375
- // Only show header if we actually have questions
1376
- await CLIUtils.displayModuleConfigHeader(moduleName, moduleConfig.header, moduleConfig.subheader);
1377
- await prompts.log.message('');
1378
- const promptedAnswers = await prompts.prompt(questions);
1379
-
1380
- // Merge prompted answers with static answers
1381
- Object.assign(allAnswers, promptedAnswers);
1382
- } else if (newStaticKeys.length > 0) {
1383
- // Only static fields, no questions - show no config message
1384
- await prompts.log.message(` \u2713 ${moduleName.toUpperCase()} module configuration updated`);
1385
- }
1386
-
1387
- // Store all answers for cross-referencing
1388
- Object.assign(this.allAnswers, allAnswers);
1389
-
1390
- // Process all answers (both static and prompted)
1391
- // First, copy existing config to preserve values that aren't being updated
1392
- if (this._existingConfig && this._existingConfig[moduleName]) {
1393
- this.collectedConfig[moduleName] = { ...this._existingConfig[moduleName] };
1394
- } else {
1395
- this.collectedConfig[moduleName] = {};
1396
- }
1397
-
1398
- for (const key of Object.keys(allAnswers)) {
1399
- const originalKey = key.replace(`${moduleName}_`, '');
1400
- const item = moduleConfig[originalKey];
1401
- const value = allAnswers[key];
1402
-
1403
- let result;
1404
- if (Array.isArray(value)) {
1405
- result = value;
1406
- } else if (item.result) {
1407
- result = this.processResultTemplate(item.result, value);
1408
- } else {
1409
- result = value;
1410
- }
1411
-
1412
- // Update the collected config with new/updated values
1413
- this.collectedConfig[moduleName][originalKey] = result;
1414
- }
1415
- }
1416
-
1417
- // Copy over existing values for fields that weren't prompted
1418
- if (this._existingConfig && this._existingConfig[moduleName]) {
1419
- if (!this.collectedConfig[moduleName]) {
1420
- this.collectedConfig[moduleName] = {};
1421
- }
1422
- for (const [key, value] of Object.entries(this._existingConfig[moduleName])) {
1423
- if (!this.collectedConfig[moduleName][key]) {
1424
- this.collectedConfig[moduleName][key] = value;
1425
- this.allAnswers[`${moduleName}_${key}`] = value;
1426
- }
1427
- }
1428
- }
1429
-
1430
- await this.displayModulePostConfigNotes(moduleName, moduleConfig);
1431
-
1432
- return newKeys.length > 0 || newStaticKeys.length > 0; // Return true if we had any new fields (interactive or static)
1433
- }
1434
-
1435
- /**
1436
- * Process a result template with value substitution
1437
- * @param {*} resultTemplate - The result template
1438
- * @param {*} value - The value to substitute
1439
- * @returns {*} Processed result
1440
- */
1441
- processResultTemplate(resultTemplate, value) {
1442
- let result = resultTemplate;
1443
-
1444
- if (typeof result === 'string' && value !== undefined) {
1445
- if (typeof value === 'string') {
1446
- result = result.replace('{value}', value);
1447
- } else if (typeof value === 'boolean' || typeof value === 'number') {
1448
- if (result === '{value}') {
1449
- result = value;
1450
- } else {
1451
- result = result.replace('{value}', value);
1452
- }
1453
- } else {
1454
- result = value;
1455
- }
1456
-
1457
- if (typeof result === 'string') {
1458
- result = result.replaceAll(/{([^}]+)}/g, (match, configKey) => {
1459
- if (configKey === 'project-root') {
1460
- return '{project-root}';
1461
- }
1462
- if (configKey === 'value') {
1463
- return match;
1464
- }
1465
-
1466
- let configValue = this.allAnswers[configKey] || this.allAnswers[`${configKey}`];
1467
- if (!configValue) {
1468
- for (const [answerKey, answerValue] of Object.entries(this.allAnswers)) {
1469
- if (answerKey.endsWith(`_${configKey}`)) {
1470
- configValue = answerValue;
1471
- break;
1472
- }
1473
- }
1474
- }
1475
-
1476
- if (!configValue) {
1477
- for (const mod of Object.keys(this.collectedConfig)) {
1478
- if (mod !== '_meta' && this.collectedConfig[mod] && this.collectedConfig[mod][configKey]) {
1479
- configValue = this.collectedConfig[mod][configKey];
1480
- if (typeof configValue === 'string' && configValue.includes('{project-root}/')) {
1481
- configValue = configValue.replace('{project-root}/', '');
1482
- }
1483
- break;
1484
- }
1485
- }
1486
- }
1487
-
1488
- return configValue || match;
1489
- });
1490
- }
1491
- }
1492
-
1493
- return result;
1494
- }
1495
-
1496
- /**
1497
- * Get the default username from the system
1498
- * @returns {string} Capitalized username\
1499
- */
1500
- getDefaultUsername() {
1501
- let result = 'BMad';
1502
- try {
1503
- const os = require('node:os');
1504
- const userInfo = os.userInfo();
1505
- if (userInfo && userInfo.username) {
1506
- const username = userInfo.username;
1507
- result = username.charAt(0).toUpperCase() + username.slice(1);
1508
- }
1509
- } catch {
1510
- // Do nothing, just return 'BMad'
1511
- }
1512
- return result;
1513
- }
1514
-
1515
- /**
1516
- * Collect configuration for a single module
1517
- * @param {string} moduleName - Module name
1518
- * @param {string} projectDir - Target project directory
1519
- * @param {boolean} skipLoadExisting - Skip loading existing config (for early core collection)
1520
- * @param {boolean} skipCompletion - Skip showing completion message (for early core collection)
1521
- */
1522
- async collectModuleConfig(moduleName, projectDir, skipLoadExisting = false, skipCompletion = false) {
1523
- this.currentProjectDir = projectDir;
1524
- // Load existing config if needed and not already loaded
1525
- if (!skipLoadExisting && !this._existingConfig) {
1526
- await this.loadExistingConfig(projectDir);
1527
- }
1528
-
1529
- // Initialize allAnswers if not already initialized
1530
- if (!this.allAnswers) {
1531
- this.allAnswers = {};
1532
- }
1533
- // Load module's config
1534
- let moduleConfigPath = path.join(getModulePath(moduleName), 'module.yaml');
1535
-
1536
- // If not found in src/modules or custom paths, search the project
1537
- if (!(await fs.pathExists(moduleConfigPath))) {
1538
- const moduleSourcePath = await this.findModuleSource(moduleName, { silent: true });
1539
-
1540
- if (moduleSourcePath) {
1541
- moduleConfigPath = path.join(moduleSourcePath, 'module.yaml');
1542
- }
1543
- }
1544
-
1545
- let configPath = null;
1546
- if (await fs.pathExists(moduleConfigPath)) {
1547
- configPath = moduleConfigPath;
1548
- } else {
1549
- // No config for this module
1550
- return;
1551
- }
1552
-
1553
- const configContent = await fs.readFile(configPath, 'utf8');
1554
- const moduleConfig = yaml.parse(configContent);
1555
-
1556
- if (!moduleConfig) {
1557
- return;
1558
- }
1559
-
1560
- // Process each config item
1561
- const questions = [];
1562
- const staticAnswers = {};
1563
- const configKeys = Object.keys(moduleConfig).filter((key) => key !== 'prompt');
1564
-
1565
- for (const key of configKeys) {
1566
- const item = moduleConfig[key];
1567
-
1568
- // Skip if not a config object
1569
- if (!item || typeof item !== 'object') {
1570
- continue;
1571
- }
1572
-
1573
- // Handle static values (no prompt, just result)
1574
- if (!item.prompt && item.result) {
1575
- // Add to static answers with a marker value
1576
- staticAnswers[`${moduleName}_${key}`] = undefined;
1577
- continue;
1578
- }
1579
-
1580
- // Handle interactive values (with prompt)
1581
- if (item.prompt) {
1582
- const question = await this.buildQuestion(moduleName, key, item, moduleConfig);
1583
- if (question) {
1584
- questions.push(question);
1585
- }
1586
- }
1587
- }
1588
-
1589
- // Collect all answers (static + prompted)
1590
- let allAnswers = { ...staticAnswers };
1591
-
1592
- // If there are questions to ask, prompt for accepting defaults vs customizing
1593
- if (questions.length > 0) {
1594
- const moduleDisplayName = moduleConfig.header || `${moduleName.toUpperCase()} Module`;
1595
-
1596
- // Skip prompts mode: use all defaults without asking
1597
- if (this.skipPrompts) {
1598
- await prompts.log.info(`Using default configuration for ${moduleDisplayName}`);
1599
- // Use defaults for all questions
1600
- for (const question of questions) {
1601
- const hasDefault = question.default !== undefined && question.default !== null && question.default !== '';
1602
- if (hasDefault && typeof question.default !== 'function') {
1603
- allAnswers[question.name] = question.default;
1604
- }
1605
- }
1606
- } else {
1607
- if (!this._silentConfig) await prompts.log.step(`Configuring ${moduleDisplayName}`);
1608
- let useDefaults = true;
1609
- if (moduleName === 'core') {
1610
- useDefaults = false; // Core: always show all questions
1611
- } else if (this.modulesToCustomize === undefined) {
1612
- // Fallback: original per-module confirm (backward compat for direct calls)
1613
- const customizeAnswer = await prompts.prompt([
1614
- {
1615
- type: 'confirm',
1616
- name: 'customize',
1617
- message: 'Accept Defaults (no to customize)?',
1618
- default: true,
1619
- },
1620
- ]);
1621
- useDefaults = customizeAnswer.customize;
1622
- } else {
1623
- // Batch mode: use defaults unless module was selected for customization
1624
- useDefaults = !this.modulesToCustomize.has(moduleName);
1625
- }
1626
-
1627
- if (useDefaults && moduleName !== 'core') {
1628
- // Accept defaults - only ask questions that have NO default value
1629
- const questionsWithoutDefaults = questions.filter((q) => q.default === undefined || q.default === null || q.default === '');
1630
-
1631
- if (questionsWithoutDefaults.length > 0) {
1632
- await prompts.log.message(` Asking required questions for ${moduleName.toUpperCase()}...`);
1633
- const promptedAnswers = await prompts.prompt(questionsWithoutDefaults);
1634
- Object.assign(allAnswers, promptedAnswers);
1635
- }
1636
-
1637
- // For questions with defaults that weren't asked, we need to process them with their default values
1638
- const questionsWithDefaults = questions.filter((q) => q.default !== undefined && q.default !== null && q.default !== '');
1639
- for (const question of questionsWithDefaults) {
1640
- // Skip function defaults - these are dynamic and will be evaluated later
1641
- if (typeof question.default === 'function') {
1642
- continue;
1643
- }
1644
- allAnswers[question.name] = question.default;
1645
- }
1646
- } else {
1647
- const promptedAnswers = await prompts.prompt(questions);
1648
- Object.assign(allAnswers, promptedAnswers);
1649
- }
1650
- }
1651
- }
1652
-
1653
- // Store all answers for cross-referencing
1654
- Object.assign(this.allAnswers, allAnswers);
1655
-
1656
- // Process all answers (both static and prompted)
1657
- // Always process if we have any answers or static answers
1658
- if (Object.keys(allAnswers).length > 0 || Object.keys(staticAnswers).length > 0) {
1659
- const answers = allAnswers;
1660
-
1661
- // Process answers and build result values
1662
- for (const key of Object.keys(answers)) {
1663
- const originalKey = key.replace(`${moduleName}_`, '');
1664
- const item = moduleConfig[originalKey];
1665
- const value = answers[key];
1666
-
1667
- // Build the result using the template
1668
- let result;
1669
-
1670
- // For arrays (multi-select), handle differently
1671
- if (Array.isArray(value)) {
1672
- result = value;
1673
- } else if (item.result) {
1674
- result = item.result;
1675
-
1676
- // Replace placeholders only for strings
1677
- if (typeof result === 'string' && value !== undefined) {
1678
- // Replace {value} with the actual value
1679
- if (typeof value === 'string') {
1680
- result = result.replace('{value}', value);
1681
- } else if (typeof value === 'boolean' || typeof value === 'number') {
1682
- // For boolean and number values, if result is just "{value}", use the raw value
1683
- if (result === '{value}') {
1684
- result = value;
1685
- } else {
1686
- result = result.replace('{value}', value);
1687
- }
1688
- } else {
1689
- result = value;
1690
- }
1691
-
1692
- // Only do further replacements if result is still a string
1693
- if (typeof result === 'string') {
1694
- // Replace references to other config values
1695
- result = result.replaceAll(/{([^}]+)}/g, (match, configKey) => {
1696
- // Check if it's a special placeholder
1697
- if (configKey === 'project-root') {
1698
- return '{project-root}';
1699
- }
1700
-
1701
- // Skip if it's the 'value' placeholder we already handled
1702
- if (configKey === 'value') {
1703
- return match;
1704
- }
1705
-
1706
- // Look for the config value across all modules
1707
- // First check if it's in the current module's answers
1708
- let configValue = answers[`${moduleName}_${configKey}`];
1709
-
1710
- // Then check all answers (for cross-module references like outputFolder)
1711
- if (!configValue) {
1712
- // Try with various module prefixes
1713
- for (const [answerKey, answerValue] of Object.entries(this.allAnswers)) {
1714
- if (answerKey.endsWith(`_${configKey}`)) {
1715
- configValue = answerValue;
1716
- break;
1717
- }
1718
- }
1719
- }
1720
-
1721
- // Check in already collected config
1722
- if (!configValue) {
1723
- for (const mod of Object.keys(this.collectedConfig)) {
1724
- if (mod !== '_meta' && this.collectedConfig[mod] && this.collectedConfig[mod][configKey]) {
1725
- configValue = this.collectedConfig[mod][configKey];
1726
- break;
1727
- }
1728
- }
1729
- }
1730
-
1731
- return configValue || match;
1732
- });
1733
- }
1734
- }
1735
- } else {
1736
- result = value;
1737
- }
1738
-
1739
- // Store only the result value (no prompts, defaults, examples, etc.)
1740
- if (!this.collectedConfig[moduleName]) {
1741
- this.collectedConfig[moduleName] = {};
1742
- }
1743
- this.collectedConfig[moduleName][originalKey] = result;
1744
- }
1745
-
1746
- // No longer display completion boxes - keep output clean
1747
- } else {
1748
- // No questions for this module - show completion message with header if available
1749
- const moduleDisplayName = moduleConfig.header || `${moduleName.toUpperCase()} Module`;
1750
-
1751
- // Check if this module has NO configuration keys at all (like CIS)
1752
- // Filter out metadata fields and only count actual config objects
1753
- const metadataFields = new Set(['code', 'name', 'header', 'subheader', 'default_selected']);
1754
- const actualConfigKeys = configKeys.filter((key) => !metadataFields.has(key));
1755
- const hasNoConfig = actualConfigKeys.length === 0;
1756
-
1757
- if (!this._silentConfig) {
1758
- if (hasNoConfig && (moduleConfig.subheader || moduleConfig.header)) {
1759
- await prompts.log.step(moduleDisplayName);
1760
- if (moduleConfig.subheader) {
1761
- await prompts.log.message(` \u2713 ${moduleConfig.subheader}`);
1762
- } else {
1763
- await prompts.log.message(` \u2713 No custom configuration required`);
1764
- }
1765
- } else {
1766
- // Module has config but just no questions to ask
1767
- await prompts.log.message(` \u2713 ${moduleName.toUpperCase()} module configured`);
1768
- }
1769
- }
1770
- }
1771
-
1772
- // If we have no collected config for this module, but we have a module schema,
1773
- // ensure we have at least an empty object
1774
- if (!this.collectedConfig[moduleName]) {
1775
- this.collectedConfig[moduleName] = {};
1776
-
1777
- // If we accepted defaults and have no answers, we still need to check
1778
- // if there are any static values in the schema that should be applied
1779
- if (moduleConfig) {
1780
- for (const key of Object.keys(moduleConfig)) {
1781
- if (key !== 'prompt' && moduleConfig[key] && typeof moduleConfig[key] === 'object') {
1782
- const item = moduleConfig[key];
1783
- // For static items (no prompt, just result), apply the result
1784
- if (!item.prompt && item.result) {
1785
- // Apply any placeholder replacements to the result
1786
- let result = item.result;
1787
- if (typeof result === 'string') {
1788
- result = this.replacePlaceholders(result, moduleName, moduleConfig);
1789
- }
1790
- this.collectedConfig[moduleName][key] = result;
1791
- }
1792
- }
1793
- }
1794
- }
1795
- }
1796
-
1797
- await this.displayModulePostConfigNotes(moduleName, moduleConfig);
1798
- }
1799
-
1800
- /**
1801
- * Replace placeholders in a string with collected config values
1802
- * @param {string} str - String with placeholders
1803
- * @param {string} currentModule - Current module name (to look up defaults in same module)
1804
- * @param {Object} moduleConfig - Current module's config schema (to look up defaults)
1805
- * @returns {string} String with placeholders replaced
1806
- */
1807
- replacePlaceholders(str, currentModule = null, moduleConfig = null) {
1808
- if (typeof str !== 'string') {
1809
- return str;
1810
- }
1811
-
1812
- return str.replaceAll(/{([^}]+)}/g, (match, configKey) => {
1813
- // Preserve special placeholders
1814
- if (configKey === 'project-root' || configKey === 'value' || configKey === 'directory_name') {
1815
- return match;
1816
- }
1817
-
1818
- const configValue = this.resolveConfigValue(configKey, currentModule, moduleConfig);
1819
-
1820
- return configValue || match;
1821
- });
1822
- }
1823
-
1824
- /**
1825
- * Clean a stored path-like value for prompt display/input reuse.
1826
- * @param {*} value - Stored value
1827
- * @returns {*} Cleaned value
1828
- */
1829
- cleanPromptValue(value) {
1830
- if (typeof value === 'string' && value.startsWith('{project-root}/')) {
1831
- return value.replace('{project-root}/', '');
1832
- }
1833
-
1834
- return value;
1835
- }
1836
-
1837
- /**
1838
- * Resolve a config key from answers, collected config, existing config, or schema defaults.
1839
- * @param {string} configKey - Config key to resolve
1840
- * @param {string} currentModule - Current module name
1841
- * @param {Object} moduleConfig - Current module config schema
1842
- * @returns {*} Resolved value
1843
- */
1844
- resolveConfigValue(configKey, currentModule = null, moduleConfig = null) {
1845
- // Look for the config value in allAnswers (already answered questions)
1846
- let configValue = this.allAnswers?.[configKey] || this.allAnswers?.[`core_${configKey}`];
1847
-
1848
- if (!configValue && this.allAnswers) {
1849
- for (const [answerKey, answerValue] of Object.entries(this.allAnswers)) {
1850
- if (answerKey.endsWith(`_${configKey}`)) {
1851
- configValue = answerValue;
1852
- break;
1853
- }
1854
- }
1855
- }
1856
-
1857
- // Prefer the current module's persisted value when re-prompting an existing install
1858
- if (!configValue && currentModule && this._existingConfig?.[currentModule]?.[configKey] !== undefined) {
1859
- configValue = this._existingConfig[currentModule][configKey];
1860
- }
1861
-
1862
- // Check in already collected config
1863
- if (!configValue) {
1864
- for (const mod of Object.keys(this.collectedConfig)) {
1865
- if (mod !== '_meta' && this.collectedConfig[mod] && this.collectedConfig[mod][configKey]) {
1866
- configValue = this.collectedConfig[mod][configKey];
1867
- break;
1868
- }
1869
- }
1870
- }
1871
-
1872
- // Fall back to other existing module config values
1873
- if (!configValue && this._existingConfig) {
1874
- for (const mod of Object.keys(this._existingConfig)) {
1875
- if (mod !== '_meta' && this._existingConfig[mod] && this._existingConfig[mod][configKey]) {
1876
- configValue = this._existingConfig[mod][configKey];
1877
- break;
1878
- }
1879
- }
1880
- }
1881
-
1882
- // If still not found and we're in the same module, use the default from the config schema
1883
- if (!configValue && currentModule && moduleConfig && moduleConfig[configKey]) {
1884
- const referencedItem = moduleConfig[configKey];
1885
- if (referencedItem && referencedItem.default !== undefined) {
1886
- configValue = referencedItem.default;
1887
- }
1888
- }
1889
-
1890
- return this.cleanPromptValue(configValue);
1891
- }
1892
-
1893
- /**
1894
- * Convert an existing stored value back into the prompt-facing value for templated fields.
1895
- * For example, "{test_artifacts}/{value}" + "_bmad-output/test-artifacts/test-design"
1896
- * becomes "test-design" so the template is not applied twice on modify.
1897
- * @param {*} existingValue - Stored config value
1898
- * @param {string} moduleName - Module name
1899
- * @param {Object} item - Config item definition
1900
- * @param {Object} moduleConfig - Current module config schema
1901
- * @returns {*} Prompt-facing default value
1902
- */
1903
- normalizeExistingValueForPrompt(existingValue, moduleName, item, moduleConfig = null) {
1904
- const cleanedValue = this.cleanPromptValue(existingValue);
1905
-
1906
- if (typeof cleanedValue !== 'string' || typeof item?.result !== 'string' || !item.result.includes('{value}')) {
1907
- return cleanedValue;
1908
- }
1909
-
1910
- const [prefixTemplate = '', suffixTemplate = ''] = item.result.split('{value}');
1911
- const prefix = this.cleanPromptValue(this.replacePlaceholders(prefixTemplate, moduleName, moduleConfig));
1912
- const suffix = this.cleanPromptValue(this.replacePlaceholders(suffixTemplate, moduleName, moduleConfig));
1913
-
1914
- if ((prefix && !cleanedValue.startsWith(prefix)) || (suffix && !cleanedValue.endsWith(suffix))) {
1915
- return cleanedValue;
1916
- }
1917
-
1918
- const startIndex = prefix.length;
1919
- const endIndex = suffix ? cleanedValue.length - suffix.length : cleanedValue.length;
1920
- if (endIndex < startIndex) {
1921
- return cleanedValue;
1922
- }
1923
-
1924
- let promptValue = cleanedValue.slice(startIndex, endIndex);
1925
- if (promptValue.startsWith('/')) {
1926
- promptValue = promptValue.slice(1);
1927
- }
1928
- if (promptValue.endsWith('/')) {
1929
- promptValue = promptValue.slice(0, -1);
1930
- }
1931
-
1932
- return promptValue || cleanedValue;
1933
- }
1934
-
1935
- /**
1936
- * Build a prompt question from a config item
1937
- * @param {string} moduleName - Module name
1938
- * @param {string} key - Config key
1939
- * @param {Object} item - Config item definition
1940
- * @param {Object} moduleConfig - Full module config schema (for resolving defaults)
1941
- */
1942
- async buildQuestion(moduleName, key, item, moduleConfig = null) {
1943
- const questionName = `${moduleName}_${key}`;
1944
-
1945
- // Check for existing value
1946
- let existingValue = null;
1947
- if (this._existingConfig && this._existingConfig[moduleName]) {
1948
- existingValue = this._existingConfig[moduleName][key];
1949
- existingValue = this.normalizeExistingValueForPrompt(existingValue, moduleName, item, moduleConfig);
1950
- }
1951
-
1952
- // Special handling for user_name: default to system user
1953
- if (moduleName === 'core' && key === 'user_name' && !existingValue) {
1954
- item.default = this.getDefaultUsername();
1955
- }
1956
-
1957
- // Determine question type and default value
1958
- let questionType = 'input';
1959
- let defaultValue = item.default;
1960
- let choices = null;
1961
-
1962
- // Check if default contains references to other fields in the same module
1963
- const hasSameModuleReference = typeof defaultValue === 'string' && defaultValue.match(/{([^}]+)}/);
1964
- let dynamicDefault = false;
1965
-
1966
- // Replace placeholders in default value with collected config values
1967
- if (typeof defaultValue === 'string') {
1968
- if (defaultValue.includes('{directory_name}') && this.currentProjectDir) {
1969
- const dirName = path.basename(this.currentProjectDir);
1970
- defaultValue = defaultValue.replaceAll('{directory_name}', dirName);
1971
- }
1972
-
1973
- // Check if this references another field in the same module (for dynamic defaults)
1974
- if (hasSameModuleReference && moduleConfig) {
1975
- const matches = defaultValue.match(/{([^}]+)}/g);
1976
- if (matches) {
1977
- for (const match of matches) {
1978
- const fieldName = match.slice(1, -1); // Remove { }
1979
- // Check if this field exists in the same module config
1980
- if (moduleConfig[fieldName]) {
1981
- dynamicDefault = true;
1982
- break;
1983
- }
1984
- }
1985
- }
1986
- }
1987
-
1988
- // If not dynamic, replace placeholders now
1989
- if (!dynamicDefault) {
1990
- defaultValue = this.replacePlaceholders(defaultValue, moduleName, moduleConfig);
1991
- }
1992
-
1993
- // Strip {project-root}/ from defaults since it will be added back by result template
1994
- // This makes the display cleaner and user input simpler
1995
- if (defaultValue.includes('{project-root}/')) {
1996
- defaultValue = defaultValue.replace('{project-root}/', '');
1997
- }
1998
- }
1999
-
2000
- // Handle different question types
2001
- if (item['single-select']) {
2002
- questionType = 'list';
2003
- choices = item['single-select'].map((choice) => {
2004
- // If choice is an object with label and value
2005
- if (typeof choice === 'object' && choice.label && choice.value !== undefined) {
2006
- return {
2007
- name: choice.label,
2008
- value: choice.value,
2009
- };
2010
- }
2011
- // Otherwise it's a simple string choice
2012
- return {
2013
- name: choice,
2014
- value: choice,
2015
- };
2016
- });
2017
- if (existingValue) {
2018
- defaultValue = existingValue;
2019
- }
2020
- } else if (item['multi-select']) {
2021
- questionType = 'checkbox';
2022
- choices = item['multi-select'].map((choice) => {
2023
- // If choice is an object with label and value
2024
- if (typeof choice === 'object' && choice.label && choice.value !== undefined) {
2025
- return {
2026
- name: choice.label,
2027
- value: choice.value,
2028
- checked: existingValue
2029
- ? existingValue.includes(choice.value)
2030
- : item.default && Array.isArray(item.default)
2031
- ? item.default.includes(choice.value)
2032
- : false,
2033
- };
2034
- }
2035
- // Otherwise it's a simple string choice
2036
- return {
2037
- name: choice,
2038
- value: choice,
2039
- checked: existingValue
2040
- ? existingValue.includes(choice)
2041
- : item.default && Array.isArray(item.default)
2042
- ? item.default.includes(choice)
2043
- : false,
2044
- };
2045
- });
2046
- } else if (typeof defaultValue === 'boolean') {
2047
- questionType = 'confirm';
2048
- }
2049
-
2050
- // Build the prompt message
2051
- let message = '';
2052
-
2053
- // Handle array prompts for multi-line messages
2054
- if (Array.isArray(item.prompt)) {
2055
- message = item.prompt.join('\n');
2056
- } else {
2057
- message = item.prompt;
2058
- }
2059
-
2060
- // Replace placeholders in prompt message with collected config values
2061
- if (typeof message === 'string') {
2062
- message = this.replacePlaceholders(message, moduleName, moduleConfig);
2063
- }
2064
-
2065
- // Add current value indicator for existing configs
2066
- const color = await prompts.getColor();
2067
- if (existingValue !== null && existingValue !== undefined) {
2068
- if (typeof existingValue === 'boolean') {
2069
- message += color.dim(` (current: ${existingValue ? 'true' : 'false'})`);
2070
- } else if (Array.isArray(existingValue)) {
2071
- message += color.dim(` (current: ${existingValue.join(', ')})`);
2072
- } else if (questionType !== 'list') {
2073
- // Show the cleaned value (without {project-root}/) for display
2074
- message += color.dim(` (current: ${existingValue})`);
2075
- }
2076
- } else if (item.example && questionType === 'input') {
2077
- // Show example for input fields
2078
- let exampleText = typeof item.example === 'string' ? item.example : JSON.stringify(item.example);
2079
- // Replace placeholders in example
2080
- if (typeof exampleText === 'string') {
2081
- exampleText = this.replacePlaceholders(exampleText, moduleName, moduleConfig);
2082
- exampleText = exampleText.replace('{project-root}/', '');
2083
- }
2084
- message += color.dim(` (e.g., ${exampleText})`);
2085
- }
2086
-
2087
- // Build the question object
2088
- const question = {
2089
- type: questionType,
2090
- name: questionName,
2091
- message: message,
2092
- };
2093
-
2094
- // Set default - if it's dynamic, use a function that the prompt will evaluate with current answers
2095
- // But if we have an existing value, always use that instead
2096
- if (existingValue !== null && existingValue !== undefined && questionType !== 'list') {
2097
- question.default = existingValue;
2098
- } else if (dynamicDefault && typeof item.default === 'string') {
2099
- const originalDefault = item.default;
2100
- question.default = (answers) => {
2101
- // Replace placeholders using answers from previous questions in the same batch
2102
- let resolved = originalDefault;
2103
- resolved = resolved.replaceAll(/{([^}]+)}/g, (match, fieldName) => {
2104
- // Look for the answer in the current batch (prefixed with module name)
2105
- const answerKey = `${moduleName}_${fieldName}`;
2106
- if (answers[answerKey] !== undefined) {
2107
- return answers[answerKey];
2108
- }
2109
- // Fall back to collected config
2110
- return this.collectedConfig[moduleName]?.[fieldName] || match;
2111
- });
2112
- // Strip {project-root}/ for cleaner display
2113
- if (resolved.includes('{project-root}/')) {
2114
- resolved = resolved.replace('{project-root}/', '');
2115
- }
2116
- return resolved;
2117
- };
2118
- } else {
2119
- question.default = defaultValue;
2120
- }
2121
-
2122
- // Add choices for select types
2123
- if (choices) {
2124
- question.choices = choices;
2125
- }
2126
-
2127
- // Add validation for input fields
2128
- if (questionType === 'input') {
2129
- question.validate = (input) => {
2130
- if (!input && item.required) {
2131
- return 'This field is required';
2132
- }
2133
- // Validate against regex pattern if provided
2134
- if (input && item.regex) {
2135
- const regex = new RegExp(item.regex);
2136
- if (!regex.test(input)) {
2137
- return `Invalid format. Must match pattern: ${item.regex}`;
2138
- }
2139
- }
2140
- return true;
2141
- };
2142
- }
2143
-
2144
- // Add validation for checkbox (multi-select) fields
2145
- if (questionType === 'checkbox' && item.required) {
2146
- question.validate = (answers) => {
2147
- if (!answers || answers.length === 0) {
2148
- return 'At least one option must be selected';
2149
- }
2150
- return true;
2151
- };
2152
- }
2153
-
2154
- return question;
2155
- }
2156
-
2157
- /**
2158
- * Display post-configuration notes for a module
2159
- * Shows prerequisite guidance based on collected config values
2160
- * Reads notes from the module's `post-install-notes` section in module.yaml
2161
- * Supports two formats:
2162
- * - Simple string: always displayed
2163
- * - Object keyed by config field name, with value-specific messages
2164
- * @param {string} moduleName - Module name
2165
- * @param {Object} moduleConfig - Parsed module.yaml content
2166
- */
2167
- async displayModulePostConfigNotes(moduleName, moduleConfig) {
2168
- if (this._silentConfig) return;
2169
- if (!moduleConfig || !moduleConfig['post-install-notes']) return;
2170
-
2171
- const notes = moduleConfig['post-install-notes'];
2172
- const color = await prompts.getColor();
2173
-
2174
- // Format 1: Simple string - always display
2175
- if (typeof notes === 'string') {
2176
- await prompts.log.message('');
2177
- for (const line of notes.trim().split('\n')) {
2178
- await prompts.log.message(color.dim(line));
2179
- }
2180
- return;
2181
- }
2182
-
2183
- // Format 2: Conditional on config values
2184
- if (typeof notes === 'object') {
2185
- const config = this.collectedConfig[moduleName];
2186
- if (!config) return;
2187
-
2188
- let hasOutput = false;
2189
- for (const [configKey, valueMessages] of Object.entries(notes)) {
2190
- const selectedValue = config[configKey];
2191
- if (!selectedValue || !valueMessages[selectedValue]) continue;
2192
-
2193
- if (hasOutput) await prompts.log.message('');
2194
- hasOutput = true;
2195
-
2196
- const message = valueMessages[selectedValue];
2197
- for (const line of message.trim().split('\n')) {
2198
- const trimmedLine = line.trim();
2199
- if (trimmedLine.endsWith(':') && !trimmedLine.startsWith(' ')) {
2200
- await prompts.log.info(color.bold(trimmedLine));
2201
- } else {
2202
- await prompts.log.message(color.dim(' ' + trimmedLine));
2203
- }
2204
- }
2205
- }
2206
- }
2207
- }
2208
-
2209
- /**
2210
- * Deep merge two objects
2211
- * @param {Object} target - Target object
2212
- * @param {Object} source - Source object
2213
- */
2214
- deepMerge(target, source) {
2215
- const result = { ...target };
2216
-
2217
- for (const key in source) {
2218
- if (source[key] && typeof source[key] === 'object' && !Array.isArray(source[key])) {
2219
- if (result[key] && typeof result[key] === 'object' && !Array.isArray(result[key])) {
2220
- result[key] = this.deepMerge(result[key], source[key]);
2221
- } else {
2222
- result[key] = source[key];
2223
- }
2224
- } else {
2225
- result[key] = source[key];
2226
- }
2227
- }
2228
-
2229
- return result;
2230
- }
2231
- }
2232
-
2233
- /**
2234
- * Parse a config.toml or config.user.toml written by writeCentralConfig.
2235
- * Only handles the subset of TOML the installer produces: [core],
2236
- * [modules.<code>], string/bool/number scalar values. [agents.*] and other
2237
- * sections are ignored. Returns a plain object keyed by section name where
2238
- * module sections use the bare code (e.g. "bmm"), not the full "modules.bmm".
2239
- */
2240
- function parseCentralToml(content) {
2241
- const result = {};
2242
- let currentSection = null;
2243
-
2244
- for (const rawLine of content.split('\n')) {
2245
- const line = rawLine.trim();
2246
- if (!line || line.startsWith('#')) continue;
2247
-
2248
- const sectionMatch = line.match(/^\[([^\]]+)\]\s*$/);
2249
- if (sectionMatch) {
2250
- const name = sectionMatch[1];
2251
- if (name === 'core') {
2252
- currentSection = 'core';
2253
- } else if (name.startsWith('modules.')) {
2254
- currentSection = name.slice('modules.'.length);
2255
- } else {
2256
- currentSection = null;
2257
- }
2258
- if (currentSection && !result[currentSection]) {
2259
- result[currentSection] = {};
2260
- }
2261
- continue;
2262
- }
2263
-
2264
- if (!currentSection) continue;
2265
-
2266
- const kvMatch = line.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\s*=\s*(.+)$/);
2267
- if (!kvMatch) continue;
2268
-
2269
- const key = kvMatch[1];
2270
- const raw = kvMatch[2].trim();
2271
- let value;
2272
- if (raw.startsWith('"') && raw.endsWith('"')) {
2273
- value = raw.slice(1, -1).replaceAll(/\\(["\\nrbt])/g, (_, c) => ({ '"': '"', '\\': '\\', n: '\n', r: '\r', b: '\b', t: '\t' })[c]);
2274
- } else if (raw === 'true') {
2275
- value = true;
2276
- } else if (raw === 'false') {
2277
- value = false;
2278
- } else if (raw !== '' && !isNaN(raw)) {
2279
- value = Number(raw);
2280
- } else {
2281
- value = raw;
2282
- }
2283
- result[currentSection][key] = value;
2284
- }
2285
-
2286
- return result;
2287
- }
2288
-
2289
- module.exports = { OfficialModules };