bmad-method-quarkus 1.0.0

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