bmad-method 6.12.4 → 7.1.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 +267 -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 +66 -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 +128 -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,1826 +0,0 @@
1
- const path = require('node:path');
2
- const fs = require('../fs-native');
3
- const { Manifest } = require('./manifest');
4
- const { OfficialModules } = require('../modules/official-modules');
5
- const { IdeManager } = require('../ide/manager');
6
- const { FileOps } = require('../file-ops');
7
- const { Config } = require('./config');
8
- const { getProjectRoot, getSourcePath } = require('../project-root');
9
- const { ManifestGenerator } = require('./manifest-generator');
10
- const prompts = require('../prompts');
11
- const { BMAD_FOLDER_NAME } = require('../ide/shared/path-utils');
12
- const { InstallPaths } = require('./install-paths');
13
- const { ExternalModuleManager } = require('../modules/external-manager');
14
- const { resolveModuleVersion } = require('../modules/version-resolver');
15
- const { MODULE_HELP_CSV_HEADER } = require('../modules/module-help-schema');
16
- const {
17
- formatRemovedShimNotice,
18
- formatRetainedShimNotice,
19
- inferShimPreference,
20
- readInstalledShims,
21
- readInstalledSkillIds,
22
- selectShimOutcome,
23
- } = require('./shim-policy');
24
-
25
- const { ExistingInstall } = require('./existing-install');
26
- const { warnPreNativeSkillsLegacy } = require('./legacy-warnings');
27
-
28
- class Installer {
29
- constructor() {
30
- this.externalModuleManager = new ExternalModuleManager();
31
- this.manifest = new Manifest();
32
- this.ideManager = new IdeManager();
33
- this.fileOps = new FileOps();
34
- this.installedFiles = new Set(); // Track all installed files
35
- this.bmadFolderName = BMAD_FOLDER_NAME;
36
- }
37
-
38
- /**
39
- * Main installation method
40
- * @param {Object} config - Installation configuration
41
- * @param {string} config.directory - Target directory
42
- * @param {string[]} config.modules - Modules to install (including 'core')
43
- * @param {string[]} config.ides - IDEs to configure
44
- */
45
- async install(originalConfig) {
46
- let updateState = null;
47
-
48
- try {
49
- const config = Config.build(originalConfig);
50
- const paths = await InstallPaths.create(config);
51
- const officialModules = await OfficialModules.build(config, paths);
52
- const existingInstall = await ExistingInstall.detect(paths.bmadDir);
53
- const availableShims = await officialModules.discoverShims(config.modules, {
54
- channelOptions: config.channelOptions,
55
- });
56
- const previousManifest = existingInstall.installed ? await this.manifest.read(paths.bmadDir) : null;
57
- const installedSkillIds = existingInstall.installed ? await readInstalledSkillIds(paths.bmadDir) : new Set();
58
- const shimPolicy = {
59
- available: availableShims.length > 0,
60
- install: inferShimPreference({
61
- requested: config.installShims,
62
- persisted: previousManifest?.installShims,
63
- availableShims,
64
- installedSkillIds,
65
- existing: existingInstall.installed,
66
- }),
67
- };
68
-
69
- const installedShims = existingInstall.installed ? await readInstalledShims(paths.bmadDir) : [];
70
- const { retained: retainedShims, removed: removedShims } = selectShimOutcome({
71
- installedShims,
72
- availableShims,
73
- install: shimPolicy.install,
74
- });
75
-
76
- // Reported here, not at the prompt, so --yes/--shims/scripted runs get it too.
77
- if (retainedShims.length > 0) {
78
- await prompts.note(formatRetainedShimNotice(retainedShims), 'Deprecated shim skills retained');
79
- }
80
- if (removedShims.length > 0) {
81
- await prompts.note(formatRemovedShimNotice(removedShims, { canReinstall: shimPolicy.available }), 'Deprecated shim skills removed');
82
- }
83
-
84
- // The notices above scroll away on a long install; repeat them in the summary.
85
- const shimStatus = { retained: retainedShims.length, removed: removedShims.length };
86
-
87
- try {
88
- await warnPreNativeSkillsLegacy({
89
- projectRoot: paths.projectRoot,
90
- existingVersion: existingInstall.installed ? existingInstall.version : null,
91
- });
92
- } catch (error) {
93
- // Legacy-dir scan is informational; never let it abort install.
94
- await prompts.log.warn(`Warning: Could not check for legacy BMAD entries: ${error.message}`);
95
- }
96
-
97
- if (existingInstall.installed) {
98
- await this._removeDeselectedModules(existingInstall, config, paths, originalConfig._preserveModules || []);
99
- updateState = await this._prepareUpdateState(paths, config, existingInstall, officialModules);
100
- await this._removeDeselectedIdes(existingInstall, config, paths);
101
- }
102
-
103
- await this._validateIdeSelection(config);
104
-
105
- // Capture pre-install module versions for from→to display
106
- const preInstallVersions = new Map();
107
- if (existingInstall.installed) {
108
- const existingModules = await this.manifest.getAllModuleVersions(paths.bmadDir);
109
- for (const mod of existingModules) {
110
- if (mod.name && mod.version) {
111
- preInstallVersions.set(mod.name, mod.version);
112
- }
113
- }
114
- }
115
-
116
- // Results collector for consolidated summary
117
- const results = [];
118
- const addResult = (step, status, detail = '', meta = {}) => results.push({ step, status, detail, ...meta });
119
-
120
- // Capture previously installed skill rows before they get overwritten
121
- const preservedModules = originalConfig._preserveModules || [];
122
- const previousSkillManifestRows = await this._readSkillManifestRows(paths.bmadDir);
123
- const previousSkillIds = this._getPreviousSkillIdsForCleanup(previousSkillManifestRows, preservedModules);
124
-
125
- const allModules = config.modules || [];
126
-
127
- await this._installAndConfigure(
128
- config,
129
- originalConfig,
130
- paths,
131
- allModules,
132
- allModules,
133
- addResult,
134
- officialModules,
135
- previousSkillManifestRows,
136
- shimPolicy,
137
- );
138
-
139
- await this._setupIdes(config, allModules, paths, addResult, previousSkillIds);
140
-
141
- // Skills are now in IDE directories — remove redundant copies from _bmad/.
142
- // Also cleans up skill dirs left by older installer versions.
143
- await this._cleanupSkillDirs(paths.bmadDir);
144
-
145
- const restoreResult = await this._restoreUserFiles(paths, updateState);
146
-
147
- // Surface any "action needed" post-install messages for installed modules
148
- // (e.g. run a setup skill) and let the user acknowledge them before the
149
- // final summary, so "BMAD is ready to use!" stays the last thing shown.
150
- await this._displayPostInstallMessages(config, officialModules);
151
-
152
- // Render consolidated summary
153
- await this.renderInstallSummary(results, {
154
- bmadDir: paths.bmadDir,
155
- modules: config.modules,
156
- ides: config.ides,
157
- customFiles: restoreResult.customFiles.length > 0 ? restoreResult.customFiles : undefined,
158
- modifiedFiles: restoreResult.modifiedFiles.length > 0 ? restoreResult.modifiedFiles : undefined,
159
- preInstallVersions,
160
- shimStatus,
161
- });
162
-
163
- return {
164
- success: true,
165
- path: paths.bmadDir,
166
- modules: config.modules,
167
- ides: config.ides,
168
- projectDir: paths.projectRoot,
169
- };
170
- } catch (error) {
171
- await prompts.log.error('Installation failed');
172
-
173
- // Clean up any temp backup directories that were created before the failure
174
- try {
175
- if (updateState?.tempBackupDir && (await fs.pathExists(updateState.tempBackupDir))) {
176
- await fs.remove(updateState.tempBackupDir);
177
- }
178
- if (updateState?.tempModifiedBackupDir && (await fs.pathExists(updateState.tempModifiedBackupDir))) {
179
- await fs.remove(updateState.tempModifiedBackupDir);
180
- }
181
- } catch {
182
- // Best-effort cleanup — don't mask the original error
183
- }
184
-
185
- throw error;
186
- }
187
- }
188
-
189
- /**
190
- * Remove modules that were previously installed but are no longer selected.
191
- * No confirmation — the user's module selection is the decision.
192
- */
193
- async _removeDeselectedModules(existingInstall, config, paths, preservedModules = []) {
194
- const previouslyInstalled = new Set(existingInstall.moduleIds);
195
- const newlySelected = new Set(config.modules || []);
196
- const preserved = new Set(preservedModules);
197
- const toRemove = [...previouslyInstalled].filter((m) => !newlySelected.has(m) && m !== 'core' && !preserved.has(m));
198
-
199
- for (const moduleId of toRemove) {
200
- const modulePath = paths.moduleDir(moduleId);
201
- try {
202
- if (await fs.pathExists(modulePath)) {
203
- await fs.remove(modulePath);
204
- }
205
- } catch (error) {
206
- await prompts.log.warn(`Warning: Failed to remove ${moduleId}: ${error.message}`);
207
- }
208
- }
209
- }
210
-
211
- /**
212
- * Fail fast if all selected IDEs are suspended.
213
- */
214
- async _validateIdeSelection(config) {
215
- if (!config.ides || config.ides.length === 0) return;
216
-
217
- await this.ideManager.ensureInitialized();
218
- const suspendedIdes = config.ides.filter((ide) => {
219
- const handler = this.ideManager.handlers.get(ide);
220
- return handler?.platformConfig?.suspended;
221
- });
222
-
223
- if (suspendedIdes.length > 0 && suspendedIdes.length === config.ides.length) {
224
- for (const ide of suspendedIdes) {
225
- const handler = this.ideManager.handlers.get(ide);
226
- await prompts.log.error(`${handler.displayName || ide}: ${handler.platformConfig.suspended}`);
227
- }
228
- throw new Error(
229
- `All selected tool(s) are suspended: ${suspendedIdes.join(', ')}. Installation aborted to prevent upgrading _bmad/ without a working IDE configuration.`,
230
- );
231
- }
232
- }
233
-
234
- /**
235
- * Remove IDEs that were previously installed but are no longer selected.
236
- * No confirmation — the user's IDE selection is the decision.
237
- */
238
- async _removeDeselectedIdes(existingInstall, config, paths) {
239
- const previouslyInstalled = new Set(existingInstall.ides);
240
- const newlySelected = new Set(config.ides || []);
241
- const toRemove = [...previouslyInstalled].filter((ide) => !newlySelected.has(ide));
242
-
243
- if (toRemove.length === 0) return;
244
-
245
- // Pass the newly-selected list as remainingIdes so cleanupByList skips
246
- // target_dir wipes for IDEs whose directory is still owned by a peer
247
- // (e.g. removing 'cursor' while 'gemini' remains — both share .agents/skills).
248
- const results = await this.ideManager.cleanupByList(paths.projectRoot, toRemove, {
249
- remainingIdes: [...newlySelected],
250
- });
251
-
252
- for (const result of results || []) {
253
- if (result && result.success === false) {
254
- await prompts.log.warn(`Warning: Failed to remove ${result.ide}: ${result.error || 'unknown error'}`);
255
- }
256
- }
257
- }
258
-
259
- /**
260
- * Install modules, create directories, generate configs and manifests.
261
- */
262
- async _installAndConfigure(
263
- config,
264
- originalConfig,
265
- paths,
266
- officialModuleIds,
267
- allModules,
268
- addResult,
269
- officialModules,
270
- previousSkillManifestRows = [],
271
- shimPolicy = null,
272
- ) {
273
- const isQuickUpdate = config.isQuickUpdate();
274
- const moduleConfigs = officialModules.moduleConfigs;
275
- const resolvedShimPolicy = shimPolicy || { available: false, install: false };
276
-
277
- const dirResults = { createdDirs: [], movedDirs: [], createdWdsFolders: [] };
278
-
279
- const installTasks = [];
280
-
281
- installTasks.push({
282
- title: 'Installing shared scripts',
283
- task: async () => {
284
- await this._installSharedScripts(paths);
285
- addResult('Shared scripts', 'ok');
286
- return 'Shared scripts installed';
287
- },
288
- });
289
-
290
- if (allModules.length > 0) {
291
- installTasks.push({
292
- title: isQuickUpdate ? `Updating ${allModules.length} module(s)` : `Installing ${allModules.length} module(s)`,
293
- task: async (message) => {
294
- const installedModuleNames = new Set();
295
-
296
- await this._installOfficialModules(config, paths, officialModuleIds, addResult, isQuickUpdate, officialModules, {
297
- message,
298
- installedModuleNames,
299
- shimPolicy: resolvedShimPolicy,
300
- });
301
-
302
- return `${allModules.length} module(s) ${isQuickUpdate ? 'updated' : 'installed'}`;
303
- },
304
- });
305
- }
306
-
307
- installTasks.push({
308
- title: 'Creating module directories',
309
- task: async (message) => {
310
- const verboseMode = process.env.BMAD_VERBOSE_INSTALL === 'true' || config.verbose;
311
- const moduleLogger = {
312
- log: async (msg) => (verboseMode ? await prompts.log.message(msg) : undefined),
313
- error: async (msg) => await prompts.log.error(msg),
314
- warn: async (msg) => await prompts.log.warn(msg),
315
- };
316
-
317
- if (config.modules && config.modules.length > 0) {
318
- for (const moduleName of config.modules) {
319
- message(`Setting up ${moduleName}...`);
320
- const result = await officialModules.createModuleDirectories(moduleName, paths.bmadDir, {
321
- installedIDEs: config.ides || [],
322
- moduleConfig: moduleConfigs[moduleName] || {},
323
- existingModuleConfig: officialModules.existingConfig?.[moduleName] || {},
324
- coreConfig: moduleConfigs.core || {},
325
- logger: moduleLogger,
326
- silent: true,
327
- });
328
- if (result) {
329
- dirResults.createdDirs.push(...result.createdDirs);
330
- dirResults.movedDirs.push(...(result.movedDirs || []));
331
- dirResults.createdWdsFolders.push(...result.createdWdsFolders);
332
- }
333
- }
334
- }
335
-
336
- addResult('Module directories', 'ok');
337
- return 'Module directories created';
338
- },
339
- });
340
-
341
- const configTask = {
342
- title: 'Generating configurations',
343
- task: async (message) => {
344
- await this.generateModuleConfigs(paths.bmadDir, moduleConfigs);
345
- addResult('Configurations', 'ok', 'generated');
346
-
347
- this.installedFiles.add(paths.manifestFile());
348
- this.installedFiles.add(paths.centralConfig());
349
- this.installedFiles.add(paths.centralUserConfig());
350
-
351
- message('Generating manifests...');
352
- const manifestGen = new ManifestGenerator();
353
- const preservedModules = originalConfig._preserveModules || [];
354
-
355
- const allModulesForManifest = config.isQuickUpdate()
356
- ? originalConfig._existingModules || allModules || []
357
- : preservedModules.length > 0
358
- ? [...allModules, ...preservedModules]
359
- : allModules || [];
360
-
361
- let modulesForCsvPreserve;
362
- if (config.isQuickUpdate()) {
363
- modulesForCsvPreserve = originalConfig._existingModules || allModules || [];
364
- } else {
365
- modulesForCsvPreserve = preservedModules.length > 0 ? [...allModules, ...preservedModules] : allModules;
366
- }
367
-
368
- await this._trackPreservedModuleFiles(paths.bmadDir, preservedModules);
369
-
370
- await manifestGen.generateManifests(paths.bmadDir, allModulesForManifest, [...this.installedFiles], {
371
- ides: config.ides || [],
372
- preservedModules: modulesForCsvPreserve,
373
- moduleConfigs,
374
- installShims: resolvedShimPolicy.install,
375
- shimsAvailable: resolvedShimPolicy.available,
376
- });
377
- await this._appendPreservedSkillManifestRows(paths.bmadDir, previousSkillManifestRows, preservedModules);
378
-
379
- // Apply post-install --set TOML patches. Runs after writeCentralConfig
380
- // (inside generateManifests above) so the patch operates on the
381
- // freshly written `_bmad/config.toml` / `_bmad/config.user.toml`.
382
- // See `tools/installer/set-overrides.js` for routing rules.
383
- if (config.setOverrides && Object.keys(config.setOverrides).length > 0) {
384
- const { applySetOverrides } = require('../set-overrides');
385
- const applied = await applySetOverrides(config.setOverrides, paths.bmadDir);
386
- if (applied.length > 0) {
387
- const summary = applied.map((a) => `${a.module}.${a.key} → ${a.file}`).join(', ');
388
- await prompts.log.info(`Applied --set overrides: ${summary}`);
389
- }
390
- }
391
-
392
- message('Generating help catalog...');
393
- await this.mergeModuleHelpCatalogs(paths.bmadDir, manifestGen.agents);
394
- addResult('Help catalog', 'ok');
395
-
396
- return 'Configurations generated';
397
- },
398
- };
399
- installTasks.push(configTask);
400
-
401
- // Run install + dirs first, then render dir output, then run config generation
402
- const mainTasks = installTasks.filter((t) => t !== configTask);
403
- await prompts.tasks(mainTasks);
404
-
405
- const color = await prompts.getColor();
406
- if (dirResults.movedDirs.length > 0) {
407
- const lines = dirResults.movedDirs.map((d) => ` ${d}`).join('\n');
408
- await prompts.log.message(color.cyan(`Moved directories:\n${lines}`));
409
- }
410
- if (dirResults.createdDirs.length > 0) {
411
- const lines = dirResults.createdDirs.map((d) => ` ${d}`).join('\n');
412
- await prompts.log.message(color.yellow(`Created directories:\n${lines}`));
413
- }
414
- if (dirResults.createdWdsFolders.length > 0) {
415
- const lines = dirResults.createdWdsFolders.map((f) => color.dim(` \u2713 ${f}/`)).join('\n');
416
- await prompts.log.message(color.cyan(`Created WDS folder structure:\n${lines}`));
417
- }
418
-
419
- await prompts.tasks([configTask]);
420
- }
421
-
422
- /**
423
- * Set up IDE integrations for each selected IDE.
424
- */
425
- async _setupIdes(config, allModules, paths, addResult, previousSkillIds = new Set()) {
426
- if (config.skipIde || !config.ides || config.ides.length === 0) return;
427
-
428
- await this.ideManager.ensureInitialized();
429
- const validIdes = config.ides.filter((ide) => ide && typeof ide === 'string');
430
-
431
- if (validIdes.length === 0) {
432
- addResult('IDE configuration', 'warn', 'no valid IDEs selected');
433
- return;
434
- }
435
-
436
- const setupResults = await this.ideManager.setupBatch(validIdes, paths.projectRoot, paths.bmadDir, {
437
- selectedModules: allModules || [],
438
- verbose: config.verbose,
439
- previousSkillIds,
440
- });
441
-
442
- for (const setupResult of setupResults) {
443
- const ide = setupResult.ide;
444
- if (setupResult.success) {
445
- addResult(ide, 'ok', setupResult.detail || '');
446
- } else {
447
- addResult(ide, 'error', setupResult.error || 'failed');
448
- }
449
- }
450
- }
451
-
452
- /**
453
- * Remove skill directories from _bmad/ after IDE installation.
454
- * Skills are self-contained in IDE directories, so _bmad/ only needs
455
- * module-level files (config.yaml, _config/, etc.).
456
- * Also cleans up skill dirs left by older installer versions.
457
- * @param {string} bmadDir - BMAD installation directory
458
- */
459
- async _cleanupSkillDirs(bmadDir) {
460
- const csv = require('csv-parse/sync');
461
- const csvPath = path.join(bmadDir, '_config', 'skill-manifest.csv');
462
- if (!(await fs.pathExists(csvPath))) return;
463
-
464
- const csvContent = await fs.readFile(csvPath, 'utf8');
465
- const records = csv.parse(csvContent, { columns: true, skip_empty_lines: true });
466
- const bmadFolderName = path.basename(bmadDir);
467
- const bmadPrefix = bmadFolderName + '/';
468
-
469
- for (const record of records) {
470
- if (!record.path) continue;
471
- const relativePath = record.path.startsWith(bmadPrefix) ? record.path.slice(bmadPrefix.length) : record.path;
472
- const sourceDir = path.dirname(path.join(bmadDir, relativePath));
473
- if (await fs.pathExists(sourceDir)) {
474
- await fs.remove(sourceDir);
475
- await this._removeEmptyParents(path.dirname(sourceDir), bmadDir);
476
- }
477
- }
478
- }
479
-
480
- /**
481
- * Remove now-empty parent directories left behind after skill dir cleanup.
482
- * Walks up from dir, stopping at (and never removing) bmadDir. Best-effort:
483
- * a directory that vanishes or fills in mid-walk just ends the walk.
484
- * @param {string} dir - Directory to start walking up from
485
- * @param {string} bmadDir - BMAD installation directory (boundary)
486
- */
487
- async _removeEmptyParents(dir, bmadDir) {
488
- let current = dir;
489
- while (true) {
490
- // Path-boundary check (not a string prefix, so siblings like _bmad2 don't match).
491
- const rel = path.relative(bmadDir, current);
492
- if (rel === '' || rel.startsWith('..') || path.isAbsolute(rel)) break;
493
- try {
494
- const entries = await fs.readdir(current);
495
- if (entries.length > 0) break;
496
- await fs.rmdir(current);
497
- } catch {
498
- break;
499
- }
500
- current = path.dirname(current);
501
- }
502
- }
503
-
504
- async _readSkillManifestRows(bmadDir) {
505
- const csvPath = path.join(bmadDir, '_config', 'skill-manifest.csv');
506
- if (!(await fs.pathExists(csvPath))) return [];
507
-
508
- try {
509
- const csvParse = require('csv-parse/sync');
510
- const content = await fs.readFile(csvPath, 'utf8');
511
- return csvParse.parse(content, { columns: true, skip_empty_lines: true });
512
- } catch (error) {
513
- await prompts.log.warn(`Failed to parse skill-manifest.csv: ${error.message}`);
514
- return [];
515
- }
516
- }
517
-
518
- _getPreviousSkillIdsForCleanup(previousRows, preservedModules = []) {
519
- const preservedModuleSet = new Set(preservedModules || []);
520
- const ids = new Set();
521
- for (const row of previousRows || []) {
522
- if (row.canonicalId && !preservedModuleSet.has(row.module)) {
523
- ids.add(row.canonicalId);
524
- }
525
- }
526
- return ids;
527
- }
528
-
529
- async _appendPreservedSkillManifestRows(bmadDir, previousRows, preservedModules = []) {
530
- if (!previousRows || previousRows.length === 0 || preservedModules.length === 0) return;
531
-
532
- const preservedModuleSet = new Set(preservedModules);
533
- const rowsToPreserve = previousRows.filter((row) => row.canonicalId && row.module && preservedModuleSet.has(row.module));
534
- if (rowsToPreserve.length === 0) return;
535
-
536
- const csvPath = path.join(bmadDir, '_config', 'skill-manifest.csv');
537
- if (!(await fs.pathExists(csvPath))) return;
538
-
539
- const currentRows = await this._readSkillManifestRows(bmadDir);
540
- const activeIds = new Set(currentRows.map((row) => row.canonicalId).filter(Boolean));
541
- const appendedRows = [];
542
-
543
- for (const row of rowsToPreserve) {
544
- if (activeIds.has(row.canonicalId)) continue;
545
- activeIds.add(row.canonicalId);
546
- appendedRows.push(
547
- [row.canonicalId, row.name || row.canonicalId, row.description || '', row.module, row.path || '']
548
- .map((field) => this.escapeCSVField(field))
549
- .join(','),
550
- );
551
- }
552
-
553
- if (appendedRows.length === 0) return;
554
-
555
- const currentContent = await fs.readFile(csvPath, 'utf8');
556
- const prefix = currentContent.endsWith('\n') ? currentContent : `${currentContent}\n`;
557
- await fs.writeFile(csvPath, prefix + appendedRows.join('\n') + '\n', 'utf8');
558
- }
559
-
560
- /**
561
- * Restore custom and modified files that were backed up before the update.
562
- * No-op for fresh installs (updateState is null).
563
- * @param {Object} paths - InstallPaths instance
564
- * @param {Object|null} updateState - From _prepareUpdateState, or null for fresh installs
565
- * @returns {Object} { customFiles, modifiedFiles } — lists of restored files
566
- */
567
- async _restoreUserFiles(paths, updateState) {
568
- const noFiles = { customFiles: [], modifiedFiles: [] };
569
-
570
- if (!updateState || (updateState.customFiles.length === 0 && updateState.modifiedFiles.length === 0)) {
571
- return noFiles;
572
- }
573
-
574
- let restoredCustomFiles = [];
575
- let restoredModifiedFiles = [];
576
-
577
- await prompts.tasks([
578
- {
579
- title: 'Finalizing installation',
580
- task: async (message) => {
581
- if (updateState.customFiles.length > 0) {
582
- message(`Restoring ${updateState.customFiles.length} custom files...`);
583
-
584
- for (const originalPath of updateState.customFiles) {
585
- const relativePath = path.relative(paths.bmadDir, originalPath);
586
- const backupPath = path.join(updateState.tempBackupDir, relativePath);
587
-
588
- if (await fs.pathExists(backupPath)) {
589
- await fs.ensureDir(path.dirname(originalPath));
590
- await fs.copy(backupPath, originalPath, { overwrite: true });
591
- }
592
- }
593
-
594
- if (updateState.tempBackupDir && (await fs.pathExists(updateState.tempBackupDir))) {
595
- await fs.remove(updateState.tempBackupDir);
596
- }
597
-
598
- restoredCustomFiles = updateState.customFiles;
599
- }
600
-
601
- if (updateState.modifiedFiles.length > 0) {
602
- restoredModifiedFiles = updateState.modifiedFiles;
603
-
604
- if (updateState.tempModifiedBackupDir && (await fs.pathExists(updateState.tempModifiedBackupDir))) {
605
- message(`Restoring ${restoredModifiedFiles.length} modified files as .bak...`);
606
-
607
- for (const modifiedFile of restoredModifiedFiles) {
608
- const relativePath = path.relative(paths.bmadDir, modifiedFile.path);
609
- const tempBackupPath = path.join(updateState.tempModifiedBackupDir, relativePath);
610
- const bakPath = modifiedFile.path + '.bak';
611
-
612
- if (await fs.pathExists(tempBackupPath)) {
613
- await fs.ensureDir(path.dirname(bakPath));
614
- await fs.copy(tempBackupPath, bakPath, { overwrite: true });
615
- }
616
- }
617
-
618
- await fs.remove(updateState.tempModifiedBackupDir);
619
- }
620
- }
621
-
622
- return 'Installation finalized';
623
- },
624
- },
625
- ]);
626
-
627
- return { customFiles: restoredCustomFiles, modifiedFiles: restoredModifiedFiles };
628
- }
629
-
630
- /**
631
- * Common update preparation: detect files, preserve core config, back up.
632
- * @param {Object} paths - InstallPaths instance
633
- * @param {Object} config - Clean config (may have coreConfig updated)
634
- * @param {Object} existingInstall - Detection result
635
- * @param {Object} officialModules - OfficialModules instance
636
- * @returns {Object} Update state: { customFiles, modifiedFiles, tempBackupDir, tempModifiedBackupDir }
637
- */
638
- async _prepareUpdateState(paths, config, existingInstall, officialModules) {
639
- // Detect custom and modified files BEFORE updating (compare current files vs files-manifest.csv)
640
- const existingFilesManifest = await this.readFilesManifest(paths.bmadDir);
641
- const { customFiles, modifiedFiles } = await this.detectCustomFiles(paths.bmadDir, existingFilesManifest);
642
-
643
- // Preserve existing core configuration during updates
644
- // (no-op for quick-update which already has core config from collectModuleConfigQuick)
645
- const coreConfigPath = paths.moduleConfig('core');
646
- if ((await fs.pathExists(coreConfigPath)) && (!config.coreConfig || Object.keys(config.coreConfig).length === 0)) {
647
- try {
648
- const yaml = require('yaml');
649
- const coreConfigContent = await fs.readFile(coreConfigPath, 'utf8');
650
- const existingCoreConfig = yaml.parse(coreConfigContent);
651
-
652
- config.coreConfig = existingCoreConfig;
653
- officialModules.moduleConfigs.core = existingCoreConfig;
654
- } catch (error) {
655
- await prompts.log.warn(`Warning: Could not read existing core config: ${error.message}`);
656
- }
657
- }
658
-
659
- const backupDirs = await this._backupUserFiles(paths, customFiles, modifiedFiles);
660
-
661
- return {
662
- customFiles,
663
- modifiedFiles,
664
- tempBackupDir: backupDirs.tempBackupDir,
665
- tempModifiedBackupDir: backupDirs.tempModifiedBackupDir,
666
- };
667
- }
668
-
669
- /**
670
- * Back up custom and modified files to temp directories before overwriting.
671
- * Returns the temp directory paths (or undefined if no files to back up).
672
- * @param {Object} paths - InstallPaths instance
673
- * @param {string[]} customFiles - Absolute paths of custom (user-added) files
674
- * @param {Object[]} modifiedFiles - Array of { path, relativePath } for modified files
675
- * @returns {Object} { tempBackupDir, tempModifiedBackupDir } — undefined if no files
676
- */
677
- async _backupUserFiles(paths, customFiles, modifiedFiles) {
678
- let tempBackupDir;
679
- let tempModifiedBackupDir;
680
-
681
- if (customFiles.length > 0) {
682
- tempBackupDir = path.join(paths.projectRoot, '_bmad-custom-backup-temp');
683
- await fs.ensureDir(tempBackupDir);
684
-
685
- for (const customFile of customFiles) {
686
- const relativePath = path.relative(paths.bmadDir, customFile);
687
- const backupPath = path.join(tempBackupDir, relativePath);
688
- await fs.ensureDir(path.dirname(backupPath));
689
- await fs.copy(customFile, backupPath);
690
- }
691
- }
692
-
693
- if (modifiedFiles.length > 0) {
694
- tempModifiedBackupDir = path.join(paths.projectRoot, '_bmad-modified-backup-temp');
695
- await fs.ensureDir(tempModifiedBackupDir);
696
-
697
- for (const modifiedFile of modifiedFiles) {
698
- const relativePath = path.relative(paths.bmadDir, modifiedFile.path);
699
- const tempBackupPath = path.join(tempModifiedBackupDir, relativePath);
700
- await fs.ensureDir(path.dirname(tempBackupPath));
701
- await fs.copy(modifiedFile.path, tempBackupPath, { overwrite: true });
702
- }
703
- }
704
-
705
- return { tempBackupDir, tempModifiedBackupDir };
706
- }
707
-
708
- /**
709
- * Sync src/scripts/* → _bmad/scripts/ so shared Python scripts
710
- * (e.g. resolve_customization.py) are available at install time.
711
- * Excludes dev-only tests and Python caches so they don't ship to users.
712
- * Wipes the destination first so files removed or renamed in source
713
- * don't linger and get recorded as installed. Also seeds
714
- * gitignore files for personal overrides and generated render snapshots.
715
- */
716
- async _installSharedScripts(paths) {
717
- const srcScriptsDir = path.join(paths.srcDir, 'src', 'scripts');
718
- if (!(await fs.pathExists(srcScriptsDir))) {
719
- throw new Error(`Shared scripts source directory not found: ${srcScriptsDir}`);
720
- }
721
-
722
- await fs.remove(paths.scriptsDir);
723
- await fs.ensureDir(paths.scriptsDir);
724
- // Ship only the runtime scripts — dev-only tests and Python caches must not land in user projects.
725
- const isInstallable = (srcPath) => {
726
- const base = path.basename(srcPath);
727
- return base !== 'tests' && base !== '__pycache__' && base !== '.pytest_cache' && !base.endsWith('.pyc');
728
- };
729
- await fs.copy(srcScriptsDir, paths.scriptsDir, { overwrite: true, filter: isInstallable });
730
- await this._trackFilesRecursive(paths.scriptsDir);
731
-
732
- const customGitignore = path.join(paths.customDir, '.gitignore');
733
- if (!(await fs.pathExists(customGitignore))) {
734
- await fs.writeFile(customGitignore, '*.user.toml\n', 'utf8');
735
- this.installedFiles.add(customGitignore);
736
- }
737
-
738
- const renderDir = path.join(paths.bmadDir, 'render');
739
- const renderGitignore = path.join(renderDir, '.gitignore');
740
- if (!(await fs.pathExists(renderGitignore))) {
741
- await fs.ensureDir(renderDir);
742
- await fs.writeFile(renderGitignore, '*\n!.gitignore\n', 'utf8');
743
- }
744
- this.installedFiles.add(renderGitignore);
745
- }
746
-
747
- async _trackFilesRecursive(dir) {
748
- const entries = await fs.readdir(dir, { withFileTypes: true });
749
- for (const entry of entries) {
750
- const full = path.join(dir, entry.name);
751
- if (entry.isDirectory()) {
752
- await this._trackFilesRecursive(full);
753
- } else if (entry.isFile()) {
754
- this.installedFiles.add(full);
755
- }
756
- }
757
- }
758
-
759
- async _trackPreservedModuleFiles(bmadDir, preservedModules = []) {
760
- for (const moduleName of preservedModules) {
761
- const modulePath = path.join(bmadDir, moduleName);
762
- if (await fs.pathExists(modulePath)) {
763
- await this._trackFilesRecursive(modulePath);
764
- }
765
- }
766
- }
767
-
768
- /**
769
- * Install official (non-custom) modules.
770
- * @param {Object} config - Installation configuration
771
- * @param {Object} paths - InstallPaths instance
772
- * @param {string[]} officialModuleIds - Official module IDs to install
773
- * @param {Function} addResult - Callback to record installation results
774
- * @param {boolean} isQuickUpdate - Whether this is a quick update
775
- * @param {Object} ctx - Shared context: { message, installedModuleNames }
776
- */
777
- async _installOfficialModules(config, paths, officialModuleIds, addResult, isQuickUpdate, officialModules, ctx) {
778
- const { message, installedModuleNames, shimPolicy } = ctx;
779
- const { CustomModuleManager } = require('../modules/custom-module-manager');
780
-
781
- for (const moduleName of officialModuleIds) {
782
- if (installedModuleNames.has(moduleName)) continue;
783
- installedModuleNames.add(moduleName);
784
-
785
- message(`${isQuickUpdate ? 'Updating' : 'Installing'} ${moduleName}...`);
786
-
787
- const moduleConfig = officialModules.moduleConfigs[moduleName] || {};
788
- const installResult = await officialModules.install(
789
- moduleName,
790
- paths.bmadDir,
791
- (filePath) => {
792
- this.installedFiles.add(filePath);
793
- },
794
- {
795
- skipModuleInstaller: true,
796
- moduleConfig: moduleConfig,
797
- installer: this,
798
- silent: true,
799
- channelOptions: config.channelOptions,
800
- installShims: shimPolicy.install,
801
- },
802
- );
803
-
804
- // Get display name from source module.yaml and resolve the freshest version metadata we can find locally.
805
- const sourcePath = await officialModules.findModuleSource(moduleName, {
806
- silent: true,
807
- channelOptions: config.channelOptions,
808
- });
809
- const moduleInfo = sourcePath ? await officialModules.getModuleInfo(sourcePath, moduleName, '') : null;
810
- const displayName = moduleInfo?.name || moduleName;
811
-
812
- const resolution = officialModules.externalModuleManager.getResolution(moduleName);
813
- const cachedResolution = CustomModuleManager._resolutionCache.get(moduleName);
814
- const versionInfo = await resolveModuleVersion(moduleName, {
815
- moduleSourcePath: sourcePath,
816
- fallbackVersion: resolution?.version || cachedResolution?.version,
817
- marketplacePluginNames: cachedResolution?.pluginName ? [cachedResolution.pluginName] : [],
818
- });
819
- // Prefer the git tag recorded by the resolution (e.g. "v1.7.0") over
820
- // the on-disk package.json (which may be ahead of the released tag).
821
- const version = resolution?.version || versionInfo.version || '';
822
- addResult(displayName, 'ok', '', {
823
- moduleCode: moduleName,
824
- newVersion: version,
825
- newChannel: resolution?.channel || null,
826
- newSha: resolution?.sha || null,
827
- });
828
- }
829
- }
830
-
831
- /**
832
- * Read files-manifest.csv
833
- * @param {string} bmadDir - BMAD installation directory
834
- * @returns {Array} Array of file entries from files-manifest.csv
835
- */
836
- async readFilesManifest(bmadDir) {
837
- const filesManifestPath = path.join(bmadDir, '_config', 'files-manifest.csv');
838
- if (!(await fs.pathExists(filesManifestPath))) {
839
- return [];
840
- }
841
-
842
- try {
843
- const content = await fs.readFile(filesManifestPath, 'utf8');
844
- const lines = content.split('\n');
845
- const files = [];
846
-
847
- for (let i = 1; i < lines.length; i++) {
848
- // Skip header
849
- const line = lines[i].trim();
850
- if (!line) continue;
851
-
852
- // Parse CSV line properly handling quoted values
853
- const parts = [];
854
- let current = '';
855
- let inQuotes = false;
856
-
857
- for (const char of line) {
858
- if (char === '"') {
859
- inQuotes = !inQuotes;
860
- } else if (char === ',' && !inQuotes) {
861
- parts.push(current);
862
- current = '';
863
- } else {
864
- current += char;
865
- }
866
- }
867
- parts.push(current); // Add last part
868
-
869
- if (parts.length >= 4) {
870
- files.push({
871
- type: parts[0],
872
- name: parts[1],
873
- module: parts[2],
874
- path: parts[3],
875
- hash: parts[4] || null, // Hash may not exist in old manifests
876
- });
877
- }
878
- }
879
-
880
- return files;
881
- } catch (error) {
882
- await prompts.log.warn('Could not read files-manifest.csv: ' + error.message);
883
- return [];
884
- }
885
- }
886
-
887
- /**
888
- * Detect custom and modified files
889
- * @param {string} bmadDir - BMAD installation directory
890
- * @param {Array} existingFilesManifest - Previous files from files-manifest.csv
891
- * @returns {Object} Object with customFiles and modifiedFiles arrays
892
- */
893
- async detectCustomFiles(bmadDir, existingFilesManifest) {
894
- const customFiles = [];
895
- const modifiedFiles = [];
896
-
897
- // Memory subtrees (v6.1: _bmad/_memory, current: _bmad/memory) hold
898
- // per-user runtime data generated by agents with sidecars. These files
899
- // aren't installer-managed and must never be reported as "custom" or
900
- // "modified" — they're user state, not user overrides.
901
- const bmadMemoryPaths = ['_memory', 'memory'];
902
-
903
- // Check if the manifest has hashes - if not, we can't detect modifications
904
- let manifestHasHashes = false;
905
- if (existingFilesManifest && existingFilesManifest.length > 0) {
906
- manifestHasHashes = existingFilesManifest.some((f) => f.hash);
907
- }
908
-
909
- // Build map of previously installed files from files-manifest.csv with their hashes
910
- const installedFilesMap = new Map();
911
- for (const fileEntry of existingFilesManifest) {
912
- if (fileEntry.path) {
913
- const absolutePath = path.join(bmadDir, fileEntry.path);
914
- installedFilesMap.set(path.normalize(absolutePath), {
915
- hash: fileEntry.hash,
916
- relativePath: fileEntry.path,
917
- });
918
- }
919
- }
920
-
921
- // Recursively scan bmadDir for all files
922
- const scanDirectory = async (dir) => {
923
- try {
924
- const entries = await fs.readdir(dir, { withFileTypes: true });
925
- for (const entry of entries) {
926
- const fullPath = path.join(dir, entry.name);
927
-
928
- if (entry.isDirectory()) {
929
- const relativeDir = path.relative(bmadDir, fullPath);
930
- // Render snapshots are generated state, not user-authored customization.
931
- if (entry.name === 'node_modules' || entry.name === '.git' || relativeDir === 'render') {
932
- continue;
933
- }
934
- await scanDirectory(fullPath);
935
- } else if (entry.isFile()) {
936
- const normalizedPath = path.normalize(fullPath);
937
- const fileInfo = installedFilesMap.get(normalizedPath);
938
-
939
- // Skip certain system files that are auto-generated
940
- const relativePath = path.relative(bmadDir, fullPath);
941
- const fileName = path.basename(fullPath);
942
-
943
- // Skip _config directory EXCEPT for modified agent customizations
944
- if (relativePath.startsWith('_config/') || relativePath.startsWith('_config\\')) {
945
- // Special handling for .customize.yaml files - only preserve if modified
946
- if (relativePath.includes('/agents/') && fileName.endsWith('.customize.yaml')) {
947
- // Check if the customization file has been modified from manifest
948
- const manifestPath = path.join(bmadDir, '_config', 'manifest.yaml');
949
- if (await fs.pathExists(manifestPath)) {
950
- const crypto = require('node:crypto');
951
- const currentContent = await fs.readFile(fullPath, 'utf8');
952
- const currentHash = crypto.createHash('sha256').update(currentContent).digest('hex');
953
-
954
- const yaml = require('yaml');
955
- const manifestContent = await fs.readFile(manifestPath, 'utf8');
956
- const manifestData = yaml.parse(manifestContent);
957
- const originalHash = manifestData.agentCustomizations?.[relativePath];
958
-
959
- // Only add to customFiles if hash differs (user modified)
960
- if (originalHash && currentHash !== originalHash) {
961
- customFiles.push(fullPath);
962
- }
963
- }
964
- }
965
- continue;
966
- }
967
-
968
- if (bmadMemoryPaths.some((mp) => relativePath === mp || relativePath.startsWith(mp + '/'))) {
969
- continue;
970
- }
971
-
972
- // Skip config.yaml files - these are regenerated on each install/update
973
- if (fileName === 'config.yaml') {
974
- continue;
975
- }
976
-
977
- if (!fileInfo) {
978
- // File not in manifest = custom file
979
- // EXCEPT: Agent .md files in module folders are generated files, not custom
980
- // Only treat .md files under _config/agents/ as custom
981
- if (!(fileName.endsWith('.md') && relativePath.includes('/agents/') && !relativePath.startsWith('_config/'))) {
982
- customFiles.push(fullPath);
983
- }
984
- } else if (manifestHasHashes && fileInfo.hash) {
985
- // File in manifest with hash - check if it was modified
986
- const currentHash = await this.manifest.calculateFileHash(fullPath);
987
- if (currentHash && currentHash !== fileInfo.hash) {
988
- // Hash changed = file was modified
989
- modifiedFiles.push({
990
- path: fullPath,
991
- relativePath: fileInfo.relativePath,
992
- });
993
- }
994
- }
995
- }
996
- }
997
- } catch {
998
- // Ignore errors scanning directories
999
- }
1000
- };
1001
-
1002
- await scanDirectory(bmadDir);
1003
- return { customFiles, modifiedFiles };
1004
- }
1005
-
1006
- /**
1007
- * Generate clean config.yaml files for each installed module
1008
- * @param {string} bmadDir - BMAD installation directory
1009
- * @param {Object} moduleConfigs - Collected configuration values
1010
- */
1011
- async generateModuleConfigs(bmadDir, moduleConfigs) {
1012
- const yaml = require('yaml');
1013
-
1014
- // Extract core config values to share with other modules
1015
- const coreConfig = moduleConfigs.core || {};
1016
-
1017
- // Get all installed module directories
1018
- const entries = await fs.readdir(bmadDir, { withFileTypes: true });
1019
- const nonModuleDirs = new Set(['_config', '_memory', 'memory', 'docs', 'scripts', 'custom', 'render']);
1020
- const installedModules = entries.filter((entry) => entry.isDirectory() && !nonModuleDirs.has(entry.name)).map((entry) => entry.name);
1021
-
1022
- // Generate config.yaml for each installed module
1023
- for (const moduleName of installedModules) {
1024
- const modulePath = path.join(bmadDir, moduleName);
1025
-
1026
- // Get module-specific config or use empty object if none
1027
- const config = moduleConfigs[moduleName] || {};
1028
-
1029
- if (await fs.pathExists(modulePath)) {
1030
- const configPath = path.join(modulePath, 'config.yaml');
1031
-
1032
- // Create header
1033
- const packageJson = require(path.join(getProjectRoot(), 'package.json'));
1034
- const header = `# ${moduleName.toUpperCase()} Module Configuration
1035
- # Generated by BMAD installer
1036
- # Version: ${packageJson.version}
1037
- # Date: ${new Date().toISOString()}
1038
-
1039
- `;
1040
-
1041
- // For non-core modules, add core config values directly
1042
- let finalConfig = { ...config };
1043
- let coreSection = '';
1044
-
1045
- if (moduleName !== 'core' && coreConfig && Object.keys(coreConfig).length > 0) {
1046
- // Add core values directly to the module config
1047
- // These will be available for reference in the module
1048
- finalConfig = {
1049
- ...config,
1050
- ...coreConfig, // Spread core config values directly into the module config
1051
- };
1052
-
1053
- // Create a comment section to identify core values
1054
- coreSection = '\n# Core Configuration Values\n';
1055
- }
1056
-
1057
- // Clean the config to remove any non-serializable values (like functions)
1058
- const cleanConfig = structuredClone(finalConfig);
1059
-
1060
- // Convert config to YAML
1061
- let yamlContent = yaml.stringify(cleanConfig, {
1062
- indent: 2,
1063
- lineWidth: 0,
1064
- minContentWidth: 0,
1065
- });
1066
-
1067
- // If we have core values, reorganize the YAML to group them with their comment
1068
- if (coreSection && moduleName !== 'core') {
1069
- // Split the YAML into lines
1070
- const lines = yamlContent.split('\n');
1071
- const moduleConfigLines = [];
1072
- const coreConfigLines = [];
1073
-
1074
- // Separate module-specific and core config lines
1075
- for (const line of lines) {
1076
- const key = line.split(':')[0].trim();
1077
- if (Object.prototype.hasOwnProperty.call(coreConfig, key)) {
1078
- coreConfigLines.push(line);
1079
- } else {
1080
- moduleConfigLines.push(line);
1081
- }
1082
- }
1083
-
1084
- // Rebuild YAML with module config first, then core config with comment
1085
- yamlContent = moduleConfigLines.join('\n');
1086
- if (coreConfigLines.length > 0) {
1087
- yamlContent += coreSection + coreConfigLines.join('\n');
1088
- }
1089
- }
1090
-
1091
- // Write the clean config file with POSIX-compliant final newline
1092
- const content = header + yamlContent;
1093
- await fs.writeFile(configPath, content.endsWith('\n') ? content : content + '\n', 'utf8');
1094
-
1095
- // Track the config file in installedFiles
1096
- this.installedFiles.add(configPath);
1097
- }
1098
- }
1099
- }
1100
-
1101
- /**
1102
- * Merge all module-help.csv files into a single bmad-help.csv.
1103
- * Scans all installed modules for module-help.csv and merges them.
1104
- * Output preserves the source schema verbatim — see schema below.
1105
- * @param {string} bmadDir - BMAD installation directory
1106
- * @param {Array<Object>} _agentEntries - Unused; retained for call-site compatibility
1107
- */
1108
- async mergeModuleHelpCatalogs(bmadDir, _agentEntries = []) {
1109
- const allRows = [];
1110
- const headerRow = MODULE_HELP_CSV_HEADER;
1111
- const COLUMN_COUNT = 13;
1112
- const PHASE_INDEX = 7;
1113
-
1114
- // Get all installed module directories
1115
- const entries = await fs.readdir(bmadDir, { withFileTypes: true });
1116
- const nonModuleDirs = new Set(['_config', '_memory', 'memory', 'docs', 'scripts', 'custom', 'render']);
1117
- const installedModules = entries.filter((entry) => entry.isDirectory() && !nonModuleDirs.has(entry.name)).map((entry) => entry.name);
1118
-
1119
- // Add core module to scan (it's installed at root level as _config, but we check src/core-skills)
1120
- const coreModulePath = getSourcePath('core-skills');
1121
- const modulePaths = new Map();
1122
-
1123
- // Map all module source paths
1124
- if (await fs.pathExists(coreModulePath)) {
1125
- modulePaths.set('core', coreModulePath);
1126
- }
1127
-
1128
- // Map installed module paths
1129
- for (const moduleName of installedModules) {
1130
- const modulePath = path.join(bmadDir, moduleName);
1131
- modulePaths.set(moduleName, modulePath);
1132
- }
1133
-
1134
- // Scan each module for module-help.csv
1135
- for (const [moduleName, modulePath] of modulePaths) {
1136
- const helpFilePath = path.join(modulePath, 'module-help.csv');
1137
-
1138
- if (await fs.pathExists(helpFilePath)) {
1139
- try {
1140
- const content = await fs.readFile(helpFilePath, 'utf8');
1141
- const lines = content.split('\n').filter((line) => line.trim() && !line.startsWith('#'));
1142
-
1143
- let headerWarned = false;
1144
- for (const line of lines) {
1145
- // Header row: warn on drift from canonical schema, then skip.
1146
- // Data rows are loaded positionally regardless, so the warning
1147
- // is advisory — the maintainer should rename their columns.
1148
- if (line.startsWith('module,')) {
1149
- if (!headerWarned && line.trim() !== headerRow) {
1150
- await prompts.log.warn(
1151
- ` ${moduleName}/module-help.csv header does not match canonical schema. ` +
1152
- `Expected: ${headerRow} | Found: ${line.trim()} | Data loaded positionally.`,
1153
- );
1154
- headerWarned = true;
1155
- }
1156
- continue;
1157
- }
1158
-
1159
- // Parse the line - handle quoted fields with commas
1160
- const columns = this.parseCSVLine(line);
1161
- if (columns.length < COLUMN_COUNT - 1) continue;
1162
-
1163
- // Pad short rows; truncate over-long rows
1164
- const padded = columns.slice(0, COLUMN_COUNT);
1165
- while (padded.length < COLUMN_COUNT) padded.push('');
1166
-
1167
- // If module column is empty, fill with this module's name
1168
- // (core stays empty so its rows render as universal tools)
1169
- if ((!padded[0] || padded[0].trim() === '') && moduleName !== 'core') {
1170
- padded[0] = moduleName;
1171
- }
1172
-
1173
- allRows.push(padded.map((c) => this.escapeCSVField(c)).join(','));
1174
- }
1175
-
1176
- if (process.env.BMAD_VERBOSE_INSTALL === 'true') {
1177
- await prompts.log.message(` Merged module-help from: ${moduleName}`);
1178
- }
1179
- } catch (error) {
1180
- await prompts.log.warn(` Warning: Failed to read module-help.csv from ${moduleName}: ${error.message}`);
1181
- }
1182
- }
1183
- }
1184
-
1185
- // Sort by module, then phase. Stable sort preserves authored order within a phase.
1186
- const decorated = allRows.map((row, index) => ({ row, index, cols: this.parseCSVLine(row) }));
1187
- decorated.sort((a, b) => {
1188
- const moduleA = (a.cols[0] || '').toLowerCase();
1189
- const moduleB = (b.cols[0] || '').toLowerCase();
1190
- if (moduleA !== moduleB) return moduleA.localeCompare(moduleB);
1191
-
1192
- const phaseA = a.cols[PHASE_INDEX] || '';
1193
- const phaseB = b.cols[PHASE_INDEX] || '';
1194
- if (phaseA !== phaseB) return phaseA.localeCompare(phaseB);
1195
-
1196
- return a.index - b.index;
1197
- });
1198
- const sortedRows = decorated.map((d) => d.row);
1199
-
1200
- // Write merged catalog
1201
- const outputDir = path.join(bmadDir, '_config');
1202
- await fs.ensureDir(outputDir);
1203
- const outputPath = path.join(outputDir, 'bmad-help.csv');
1204
-
1205
- const mergedContent = [headerRow, ...sortedRows].join('\n');
1206
- await fs.writeFile(outputPath, mergedContent, 'utf8');
1207
-
1208
- // Track the installed file
1209
- this.installedFiles.add(outputPath);
1210
-
1211
- if (process.env.BMAD_VERBOSE_INSTALL === 'true') {
1212
- await prompts.log.message(` Generated bmad-help.csv: ${sortedRows.length} workflows`);
1213
- }
1214
- }
1215
-
1216
- /**
1217
- * Render a consolidated install summary using prompts.note()
1218
- * @param {Array} results - Array of {step, status: 'ok'|'error'|'warn', detail}
1219
- * @param {Object} context - {bmadDir, modules, ides, customFiles, modifiedFiles}
1220
- */
1221
- async renderInstallSummary(results, context = {}) {
1222
- const color = await prompts.getColor();
1223
- const selectedIdes = new Set((context.ides || []).map((ide) => String(ide).toLowerCase()));
1224
-
1225
- // Build step lines with status indicators
1226
- const preVersions = context.preInstallVersions || new Map();
1227
- const lines = [];
1228
- for (const r of results) {
1229
- const stepLabel = r.step;
1230
-
1231
- let icon;
1232
- if (r.status === 'ok') {
1233
- icon = color.green('\u2713');
1234
- } else if (r.status === 'warn') {
1235
- icon = color.yellow('!');
1236
- } else {
1237
- icon = color.red('\u2717');
1238
- }
1239
-
1240
- // Build version detail for module results
1241
- let detail = '';
1242
- if (r.moduleCode && r.newVersion) {
1243
- const oldVersion = preVersions.get(r.moduleCode);
1244
- // Format a version label for display:
1245
- // "main" → "main @ <short-sha>" (next channel shows what SHA landed)
1246
- // "v1.7.0" or "1.7.0" → "v1.7.0" (prefix 'v' when missing)
1247
- // anything else (legacy strings) → as-is
1248
- const fmt = (v, sha) => {
1249
- if (typeof v !== 'string' || !v) return '';
1250
- if (v === 'main' || v === 'HEAD') return sha ? `main @ ${sha.slice(0, 7)}` : 'main';
1251
- if (/^v?\d+\.\d+\.\d+/.test(v)) return v.startsWith('v') ? v : `v${v}`;
1252
- return v;
1253
- };
1254
- const newV = fmt(r.newVersion, r.newSha);
1255
- // 'main'/'HEAD' strings only identify the channel, not the commit, so
1256
- // we can't assert "no change" without comparing SHAs — and preVersions
1257
- // doesn't carry the old SHA. Render these as a refresh instead of a
1258
- // false-negative "no change".
1259
- const isMainLike = oldVersion === 'main' || oldVersion === 'HEAD';
1260
- if (oldVersion && oldVersion === r.newVersion && !isMainLike) {
1261
- detail = ` (${newV}, no change)`;
1262
- } else if (oldVersion && isMainLike) {
1263
- detail = ` (${newV}, refreshed)`;
1264
- } else if (oldVersion) {
1265
- detail = ` (${fmt(oldVersion, r.newSha)} → ${newV})`;
1266
- } else {
1267
- detail = ` (${newV}, installed)`;
1268
- }
1269
- } else if (r.detail) {
1270
- detail = ` (${r.detail})`;
1271
- }
1272
- lines.push(` ${icon} ${stepLabel}${detail}`);
1273
- }
1274
-
1275
- if ((context.ides || []).length === 0) {
1276
- lines.push(` ${color.green('\u2713')} No IDE selected (installed in _bmad only)`);
1277
- }
1278
-
1279
- // Context and warnings
1280
- lines.push('');
1281
- if (context.bmadDir) {
1282
- lines.push(` Installed to: ${context.bmadDir}`);
1283
- }
1284
- if (context.customFiles && context.customFiles.length > 0) {
1285
- lines.push(` ${color.cyan(`Custom files preserved: ${context.customFiles.length}`)}`);
1286
- }
1287
- if (context.modifiedFiles && context.modifiedFiles.length > 0) {
1288
- lines.push(` ${color.yellow(`Modified files backed up (.bak): ${context.modifiedFiles.length}`)}`);
1289
- }
1290
- if (context.shimStatus?.retained > 0) {
1291
- lines.push(` ${color.yellow(`Deprecated shim skills retained: ${context.shimStatus.retained}`)} (re-run to remove them)`);
1292
- }
1293
- if (context.shimStatus?.removed > 0) {
1294
- lines.push(` ${color.green(`Deprecated shim skills removed: ${context.shimStatus.removed}`)}`);
1295
- }
1296
-
1297
- // Next steps
1298
- lines.push(
1299
- '',
1300
- ' Get started:',
1301
- ` 1. Launch your AI agent from your project folder`,
1302
- ` 2. Not sure what to do? Invoke the ${color.cyan('bmad-help')} skill and ask it what to do!`,
1303
- );
1304
-
1305
- // Repeat the uv warning here when it applies. The pre-install probe fires
1306
- // before every prompt in the run, so by now it is far up the scrollback —
1307
- // and this box is titled "BMAD is ready to use!", which is only true if
1308
- // the rendered skills can actually start.
1309
- const { detectUv } = require('./uv-check');
1310
- if (!detectUv()) {
1311
- lines.push(
1312
- '',
1313
- ` ${color.yellow('⚠ uv is not installed.')} ${color.cyan('bmad-build')} and ${color.cyan('bmad-build-auto')} render through`,
1314
- ` ${color.cyan('uv run')} and will halt on activation until you set it up — ask your agent to`,
1315
- ` "install and set up uv for me", or see https://docs.astral.sh/uv/`,
1316
- );
1317
- }
1318
-
1319
- lines.push(
1320
- '',
1321
- ` Blog, Docs and Guides: ${color.blue('https://bmadcode.com/')}`,
1322
- ` Community: ${color.blue('https://discord.gg/gk8jAdXWmj')}`,
1323
- );
1324
-
1325
- await prompts.box(lines.join('\n'), 'BMAD is ready to use!', {
1326
- rounded: true,
1327
- formatBorder: color.green,
1328
- });
1329
-
1330
- const { MessageLoader } = require('../message-loader');
1331
- await new MessageLoader().displayEndMessage();
1332
- }
1333
-
1334
- /**
1335
- * Display registry-defined post-install messages for the modules installed in
1336
- * this run. These are "action needed" notices (e.g. "run the bmad-loop-setup
1337
- * skill") that the user must see to finish setup. They are defined via the
1338
- * `post-install-message` property on a module's bmad-modules.yaml entry.
1339
- *
1340
- * Interactive installs require the user to acknowledge each message (press
1341
- * Enter); non-interactive (--yes / skipPrompts) installs print the message
1342
- * and continue without blocking, so CI/scripted installs don't hang.
1343
- *
1344
- * @param {Object} config - Install config (config.modules, config.skipPrompts)
1345
- * @param {Object} officialModules - OfficialModules instance (carries the registry)
1346
- */
1347
- async _displayPostInstallMessages(config, officialModules) {
1348
- const moduleCodes = config.modules || [];
1349
- if (moduleCodes.length === 0) return;
1350
-
1351
- const externalManager = officialModules.externalModuleManager;
1352
- if (!externalManager) return;
1353
-
1354
- const color = await prompts.getColor();
1355
-
1356
- for (const code of moduleCodes) {
1357
- let moduleInfo;
1358
- try {
1359
- moduleInfo = await externalManager.getModuleByCode(code);
1360
- } catch {
1361
- continue; // Built-in modules (core/bmm) aren't in the registry — skip.
1362
- }
1363
-
1364
- const message = moduleInfo && moduleInfo.postInstallMessage;
1365
- if (!message) continue;
1366
-
1367
- await prompts.box(String(message).trim(), `⚑ Action needed — ${moduleInfo.name || code}`, {
1368
- rounded: true,
1369
- formatBorder: color.yellow,
1370
- });
1371
-
1372
- // Interactive: require the user to acknowledge before continuing. Skip the
1373
- // blocking prompt in non-interactive installs (the message is still shown).
1374
- if (!config.skipPrompts) {
1375
- await prompts.text({
1376
- message: 'Press Enter to acknowledge',
1377
- placeholder: '',
1378
- default: '',
1379
- });
1380
- }
1381
- }
1382
- }
1383
-
1384
- /**
1385
- * Quick update method - preserves all settings and only prompts for new config fields
1386
- * @param {Object} config - Configuration with directory
1387
- * @returns {Object} Update result
1388
- */
1389
- async quickUpdate(config) {
1390
- const projectDir = path.resolve(config.directory);
1391
- const { bmadDir } = await this.findBmadDir(projectDir);
1392
-
1393
- // Check if bmad directory exists
1394
- if (!(await fs.pathExists(bmadDir))) {
1395
- throw new Error(`BMAD not installed at ${bmadDir}. Use regular install for first-time setup.`);
1396
- }
1397
-
1398
- // Detect existing installation
1399
- const existingInstall = await ExistingInstall.detect(bmadDir);
1400
- const configuredIdes = existingInstall.ides;
1401
- const projectRoot = path.dirname(bmadDir);
1402
-
1403
- // Resolve any legacy/aliased module codes (e.g. an install recorded as
1404
- // `bauto` before the registry renamed it to `bmad-loop`) to their current
1405
- // canonical code up front. Without this, a renamed module's old installs
1406
- // would fall out of `availableModuleIds` below and get silently frozen
1407
- // (see the `baut` → `automator` incident in CHANGELOG v6.7.1) instead of
1408
- // migrating forward.
1409
- const aliasMigrations = [];
1410
- const seenModuleIds = new Set();
1411
- const installedModules = [];
1412
- for (const rawId of existingInstall.moduleIds) {
1413
- const canonicalId = await this.externalModuleManager.resolveCanonicalCode(rawId);
1414
- if (canonicalId !== rawId) {
1415
- aliasMigrations.push({ from: rawId, to: canonicalId });
1416
- }
1417
- if (!seenModuleIds.has(canonicalId)) {
1418
- seenModuleIds.add(canonicalId);
1419
- installedModules.push(canonicalId);
1420
- }
1421
- }
1422
- for (const { from, to } of aliasMigrations) {
1423
- await prompts.log.info(`Migrating installed module '${from}' to its renamed successor '${to}'.`);
1424
- }
1425
-
1426
- // Get available modules (what we have source for)
1427
- const availableModulesData = await new OfficialModules().listAvailable();
1428
- const availableModules = [...availableModulesData.modules];
1429
-
1430
- // Add external official modules to available modules
1431
- const externalModules = await this.externalModuleManager.listAvailable();
1432
- for (const externalModule of externalModules) {
1433
- if (installedModules.includes(externalModule.code) && !availableModules.some((m) => m.id === externalModule.code)) {
1434
- availableModules.push({
1435
- id: externalModule.code,
1436
- name: externalModule.name,
1437
- isExternal: true,
1438
- fromExternal: true,
1439
- });
1440
- }
1441
- }
1442
-
1443
- // Add installed custom modules to available modules
1444
- const { CustomModuleManager } = require('../modules/custom-module-manager');
1445
- const customMgr = new CustomModuleManager();
1446
- for (const moduleId of installedModules) {
1447
- if (!availableModules.some((m) => m.id === moduleId)) {
1448
- const customSource = await customMgr.findModuleSourceByCode(moduleId, { bmadDir });
1449
- if (customSource) {
1450
- availableModules.push({
1451
- id: moduleId,
1452
- name: moduleId,
1453
- isExternal: true,
1454
- fromCustom: true,
1455
- });
1456
- }
1457
- }
1458
- }
1459
-
1460
- const availableModuleIds = new Set(availableModules.map((m) => m.id));
1461
-
1462
- // Only update modules that are BOTH installed AND available (we have source for)
1463
- const modulesToUpdate = installedModules.filter((id) => availableModuleIds.has(id));
1464
- const skippedModules = installedModules.filter((id) => !availableModuleIds.has(id));
1465
-
1466
- if (skippedModules.length > 0) {
1467
- await prompts.log.warn(`Skipping ${skippedModules.length} module(s) - no source available: ${skippedModules.join(', ')}`);
1468
- }
1469
-
1470
- // Build channel options from the existing manifest FIRST so the config
1471
- // collector below (which triggers external-module clones via
1472
- // findModuleSource) knows each module's recorded channel and doesn't
1473
- // silently redecide it. Without this, modules previously on 'next' or
1474
- // 'pinned' would trigger a stable-channel tag lookup at config-collection
1475
- // time, burning GitHub API quota and potentially failing.
1476
- const manifestData = await this.manifest.read(bmadDir);
1477
- const channelOptions = { global: null, nextSet: new Set(), stableSet: new Set(), pins: new Map(), warnings: [] };
1478
- if (manifestData?.modulesDetailed) {
1479
- const { fetchStableTags, classifyUpgrade, parseGitHubRepo } = require('../modules/channel-resolver');
1480
- for (const entry of manifestData.modulesDetailed) {
1481
- if (!entry?.name || !entry?.channel) continue;
1482
- if (entry.channel === 'pinned' && entry.version) {
1483
- channelOptions.pins.set(entry.name, entry.version);
1484
- continue;
1485
- }
1486
- if (entry.channel === 'next') {
1487
- channelOptions.nextSet.add(entry.name);
1488
- continue;
1489
- }
1490
- // Stable: classify the available upgrade. Patches and minors fall
1491
- // through (stable default picks up the top tag). A major upgrade
1492
- // requires opt-in, so under quick-update's non-interactive semantics
1493
- // we pin to the current version to prevent a silent breaking jump.
1494
- if (entry.channel === 'stable' && entry.version && entry.repoUrl) {
1495
- const parsed = parseGitHubRepo(entry.repoUrl);
1496
- if (!parsed) continue;
1497
- try {
1498
- const tags = await fetchStableTags(parsed.owner, parsed.repo);
1499
- if (tags.length === 0) continue;
1500
- const topTag = tags[0].tag;
1501
- const cls = classifyUpgrade(entry.version, topTag);
1502
- if (cls === 'major') {
1503
- channelOptions.pins.set(entry.name, entry.version);
1504
- await prompts.log.warn(
1505
- `${entry.name} ${entry.version} → ${topTag} is a new major release; staying on ${entry.version}. ` +
1506
- `Run \`bmad install\` (Modify) with \`--pin ${entry.name}=${topTag}\` to accept.`,
1507
- );
1508
- }
1509
- } catch (error) {
1510
- // Tag lookup failed (offline, rate-limited). Stay on the current
1511
- // version rather than guessing — the existing cache is already
1512
- // at that ref, so re-using it keeps the install stable.
1513
- channelOptions.pins.set(entry.name, entry.version);
1514
- await prompts.log.warn(`Could not check ${entry.name} for updates (${error.message}); staying on ${entry.version}.`);
1515
- }
1516
- }
1517
- }
1518
- }
1519
-
1520
- // Load existing configs and collect new fields (if any)
1521
- await prompts.log.info('Checking for new configuration options...');
1522
- const quickModules = new OfficialModules({ channelOptions });
1523
- await quickModules.loadExistingConfig(projectDir);
1524
-
1525
- let promptedForNewFields = false;
1526
-
1527
- const corePrompted = await quickModules.collectModuleConfigQuick('core', projectDir, true);
1528
- if (corePrompted) {
1529
- promptedForNewFields = true;
1530
- }
1531
-
1532
- for (const moduleName of modulesToUpdate) {
1533
- if (moduleName === 'core') continue; // Already collected above
1534
- const modulePrompted = await quickModules.collectModuleConfigQuick(moduleName, projectDir, true);
1535
- if (modulePrompted) {
1536
- promptedForNewFields = true;
1537
- }
1538
- }
1539
-
1540
- if (!promptedForNewFields) {
1541
- await prompts.log.success('All configuration is up to date, no new options to configure');
1542
- }
1543
-
1544
- quickModules.collectedConfig._meta = {
1545
- version: require(path.join(getProjectRoot(), 'package.json')).version,
1546
- installDate: new Date().toISOString(),
1547
- lastModified: new Date().toISOString(),
1548
- };
1549
-
1550
- // Build config and delegate to install()
1551
- const installConfig = {
1552
- directory: projectDir,
1553
- modules: modulesToUpdate,
1554
- ides: configuredIdes,
1555
- coreConfig: quickModules.collectedConfig.core,
1556
- moduleConfigs: quickModules.collectedConfig,
1557
- // Forward `--set` overrides so the post-install patch step
1558
- // (`applySetOverrides`) runs at the end of quick-update too. The
1559
- // installer.install path applies them after writeCentralConfig.
1560
- setOverrides: config.setOverrides || {},
1561
- installShims: config.installShims,
1562
- actionType: 'install',
1563
- _quickUpdate: true,
1564
- _preserveModules: skippedModules,
1565
- _existingModules: installedModules,
1566
- channelOptions,
1567
- };
1568
-
1569
- await this.install(installConfig);
1570
-
1571
- // Now that the canonical module has been installed successfully, remove
1572
- // the stale directory left behind under its old code so the two don't
1573
- // coexist (e.g. `_bmad/bauto/` once `_bmad/bmad-loop/` is in place).
1574
- for (const { from, to } of aliasMigrations) {
1575
- if (!modulesToUpdate.includes(to)) continue; // new code wasn't actually installed this run
1576
- const oldModuleDir = path.join(bmadDir, from);
1577
- if (await fs.pathExists(oldModuleDir)) {
1578
- await fs.remove(oldModuleDir);
1579
- await prompts.log.success(`Removed legacy '${from}' directory after migrating to '${to}'.`);
1580
- }
1581
- }
1582
-
1583
- return {
1584
- success: true,
1585
- moduleCount: modulesToUpdate.length,
1586
- hadNewFields: promptedForNewFields,
1587
- modules: modulesToUpdate,
1588
- skippedModules: skippedModules,
1589
- ides: configuredIdes,
1590
- };
1591
- }
1592
-
1593
- /**
1594
- * Uninstall BMAD with selective removal options
1595
- * @param {string} directory - Project directory
1596
- * @param {Object} options - Uninstall options
1597
- * @param {boolean} [options.removeModules=true] - Remove _bmad/ directory
1598
- * @param {boolean} [options.removeIdeConfigs=true] - Remove IDE configurations
1599
- * @param {boolean} [options.removeOutputFolder=false] - Remove user artifacts output folder
1600
- * @returns {Object} Result with success status and removed components
1601
- */
1602
- async uninstall(directory, options = {}) {
1603
- const projectDir = path.resolve(directory);
1604
- const { bmadDir } = await this.findBmadDir(projectDir);
1605
-
1606
- if (!(await fs.pathExists(bmadDir))) {
1607
- return { success: false, reason: 'not-installed' };
1608
- }
1609
-
1610
- // 1. DETECT: Read state BEFORE deleting anything
1611
- const existingInstall = await ExistingInstall.detect(bmadDir);
1612
- const outputFolder = await this._readOutputFolder(bmadDir);
1613
-
1614
- const removed = { modules: false, ideConfigs: false, outputFolder: false };
1615
-
1616
- // 2. IDE CLEANUP (before _bmad/ deletion so configs are accessible)
1617
- if (options.removeIdeConfigs !== false) {
1618
- await this.uninstallIdeConfigs(projectDir, existingInstall, { silent: options.silent });
1619
- removed.ideConfigs = true;
1620
- }
1621
-
1622
- // 3. OUTPUT FOLDER (only if explicitly requested)
1623
- if (options.removeOutputFolder === true && outputFolder) {
1624
- removed.outputFolder = await this.uninstallOutputFolder(projectDir, outputFolder);
1625
- }
1626
-
1627
- // 4. BMAD DIRECTORY (last, after everything that needs it)
1628
- if (options.removeModules !== false) {
1629
- removed.modules = await this.uninstallModules(projectDir);
1630
- }
1631
-
1632
- return { success: true, removed, version: existingInstall.installed ? existingInstall.version : null };
1633
- }
1634
-
1635
- /**
1636
- * Uninstall IDE configurations only
1637
- * @param {string} projectDir - Project directory
1638
- * @param {Object} existingInstall - Detection result from detector.detect()
1639
- * @param {Object} [options] - Options (e.g. { silent: true })
1640
- * @returns {Promise<Object>} Results from IDE cleanup
1641
- */
1642
- async uninstallIdeConfigs(projectDir, existingInstall, options = {}) {
1643
- await this.ideManager.ensureInitialized();
1644
- const cleanupOptions = { isUninstall: true, silent: options.silent };
1645
- const ideList = existingInstall.ides;
1646
- if (ideList.length > 0) {
1647
- return this.ideManager.cleanupByList(projectDir, ideList, cleanupOptions);
1648
- }
1649
- return this.ideManager.cleanup(projectDir, cleanupOptions);
1650
- }
1651
-
1652
- /**
1653
- * Remove user artifacts output folder
1654
- * @param {string} projectDir - Project directory
1655
- * @param {string} outputFolder - Output folder name (relative)
1656
- * @returns {Promise<boolean>} Whether the folder was removed
1657
- */
1658
- async uninstallOutputFolder(projectDir, outputFolder) {
1659
- if (!outputFolder) return false;
1660
- const resolvedProject = path.resolve(projectDir);
1661
- const outputPath = path.resolve(resolvedProject, outputFolder);
1662
- if (!outputPath.startsWith(resolvedProject + path.sep)) {
1663
- return false;
1664
- }
1665
- if (await fs.pathExists(outputPath)) {
1666
- await fs.remove(outputPath);
1667
- return true;
1668
- }
1669
- return false;
1670
- }
1671
-
1672
- /**
1673
- * Remove the _bmad/ directory
1674
- * @param {string} projectDir - Project directory
1675
- * @returns {Promise<boolean>} Whether the directory was removed
1676
- */
1677
- async uninstallModules(projectDir) {
1678
- const { bmadDir } = await this.findBmadDir(projectDir);
1679
- if (await fs.pathExists(bmadDir)) {
1680
- await fs.remove(bmadDir);
1681
- return true;
1682
- }
1683
- return false;
1684
- }
1685
-
1686
- /**
1687
- * Get installation status
1688
- */
1689
- async getStatus(directory) {
1690
- const projectDir = path.resolve(directory);
1691
- const { bmadDir } = await this.findBmadDir(projectDir);
1692
- return await ExistingInstall.detect(bmadDir);
1693
- }
1694
-
1695
- /**
1696
- * Get available modules
1697
- */
1698
- async getAvailableModules() {
1699
- return await new OfficialModules().listAvailable();
1700
- }
1701
-
1702
- /**
1703
- * Get the configured output folder name for a project
1704
- * Resolves bmadDir internally from projectDir
1705
- * @param {string} projectDir - Project directory
1706
- * @returns {string} Output folder name (relative, default: '_bmad-output')
1707
- */
1708
- async getOutputFolder(projectDir) {
1709
- const { bmadDir } = await this.findBmadDir(projectDir);
1710
- return this._readOutputFolder(bmadDir);
1711
- }
1712
-
1713
- /**
1714
- * Find the bmad installation directory in a project
1715
- * Always uses the standard _bmad folder name
1716
- * @param {string} projectDir - Project directory
1717
- * @returns {Promise<Object>} { bmadDir: string }
1718
- */
1719
- async findBmadDir(projectDir) {
1720
- const bmadDir = path.join(projectDir, BMAD_FOLDER_NAME);
1721
- return { bmadDir };
1722
- }
1723
-
1724
- /**
1725
- * Read the output_folder setting from module config files
1726
- * Checks bmm/config.yaml first, then other module configs
1727
- * @param {string} bmadDir - BMAD installation directory
1728
- * @returns {string} Output folder path or default
1729
- */
1730
- async _readOutputFolder(bmadDir) {
1731
- const yaml = require('yaml');
1732
-
1733
- // Check bmm/config.yaml first (most common)
1734
- const bmmConfigPath = path.join(bmadDir, 'bmm', 'config.yaml');
1735
- if (await fs.pathExists(bmmConfigPath)) {
1736
- try {
1737
- const content = await fs.readFile(bmmConfigPath, 'utf8');
1738
- const config = yaml.parse(content);
1739
- if (config && config.output_folder) {
1740
- // Strip {project-root}/ prefix if present
1741
- return config.output_folder.replace(/^\{project-root\}[/\\]/, '');
1742
- }
1743
- } catch {
1744
- // Fall through to other modules
1745
- }
1746
- }
1747
-
1748
- // Scan other module config.yaml files
1749
- try {
1750
- const entries = await fs.readdir(bmadDir, { withFileTypes: true });
1751
- for (const entry of entries) {
1752
- if (!entry.isDirectory() || entry.name === 'bmm' || entry.name.startsWith('_')) continue;
1753
- const configPath = path.join(bmadDir, entry.name, 'config.yaml');
1754
- if (await fs.pathExists(configPath)) {
1755
- try {
1756
- const content = await fs.readFile(configPath, 'utf8');
1757
- const config = yaml.parse(content);
1758
- if (config && config.output_folder) {
1759
- return config.output_folder.replace(/^\{project-root\}[/\\]/, '');
1760
- }
1761
- } catch {
1762
- // Continue scanning
1763
- }
1764
- }
1765
- }
1766
- } catch {
1767
- // Directory scan failed
1768
- }
1769
-
1770
- // Default fallback
1771
- return '_bmad-output';
1772
- }
1773
-
1774
- /**
1775
- * Parse a CSV line, handling quoted fields
1776
- * @param {string} line - CSV line to parse
1777
- * @returns {Array} Array of field values
1778
- */
1779
- parseCSVLine(line) {
1780
- const result = [];
1781
- let current = '';
1782
- let inQuotes = false;
1783
-
1784
- for (let i = 0; i < line.length; i++) {
1785
- const char = line[i];
1786
- const nextChar = line[i + 1];
1787
-
1788
- if (char === '"') {
1789
- if (inQuotes && nextChar === '"') {
1790
- // Escaped quote
1791
- current += '"';
1792
- i++; // Skip next quote
1793
- } else {
1794
- // Toggle quote mode
1795
- inQuotes = !inQuotes;
1796
- }
1797
- } else if (char === ',' && !inQuotes) {
1798
- result.push(current);
1799
- current = '';
1800
- } else {
1801
- current += char;
1802
- }
1803
- }
1804
- result.push(current);
1805
- return result;
1806
- }
1807
-
1808
- /**
1809
- * Escape a CSV field if it contains special characters
1810
- * @param {string} field - Field value to escape
1811
- * @returns {string} Escaped field
1812
- */
1813
- escapeCSVField(field) {
1814
- if (field === null || field === undefined) {
1815
- return '';
1816
- }
1817
- const str = String(field);
1818
- // If field contains comma, quote, or newline, wrap in quotes and escape inner quotes
1819
- if (str.includes(',') || str.includes('"') || str.includes('\n')) {
1820
- return `"${str.replaceAll('"', '""')}"`;
1821
- }
1822
- return str;
1823
- }
1824
- }
1825
-
1826
- module.exports = { Installer };