mdan-cli 2.5.1 → 2.5.2

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 (706) hide show
  1. package/.augment/code_review_guidelines.yaml +271 -0
  2. package/.claude/skills/bmad-os-audit-file-refs/SKILL.md +6 -0
  3. package/.claude/skills/bmad-os-audit-file-refs/prompts/instructions.md +59 -0
  4. package/.claude/skills/bmad-os-changelog-social/SKILL.md +177 -0
  5. package/.claude/skills/bmad-os-changelog-social/examples/discord-example.md +53 -0
  6. package/.claude/skills/bmad-os-changelog-social/examples/linkedin-example.md +49 -0
  7. package/.claude/skills/bmad-os-changelog-social/examples/twitter-example.md +55 -0
  8. package/.claude/skills/bmad-os-diataxis-style-fix/SKILL.md +6 -0
  9. package/.claude/skills/bmad-os-diataxis-style-fix/prompts/instructions.md +229 -0
  10. package/.claude/skills/bmad-os-draft-changelog/SKILL.md +6 -0
  11. package/.claude/skills/bmad-os-draft-changelog/prompts/instructions.md +82 -0
  12. package/.claude/skills/bmad-os-gh-triage/SKILL.md +6 -0
  13. package/.claude/skills/bmad-os-gh-triage/prompts/agent-prompt.md +60 -0
  14. package/.claude/skills/bmad-os-gh-triage/prompts/instructions.md +74 -0
  15. package/.claude/skills/bmad-os-release-module/SKILL.md +6 -0
  16. package/.claude/skills/bmad-os-release-module/prompts/instructions.md +53 -0
  17. package/.claude/skills/bmad-os-review-pr/SKILL.md +6 -0
  18. package/.claude/skills/bmad-os-review-pr/prompts/instructions.md +231 -0
  19. package/.claude/skills/bmad-os-root-cause-analysis/SKILL.md +12 -0
  20. package/.claude/skills/bmad-os-root-cause-analysis/prompts/instructions.md +74 -0
  21. package/.coderabbit.yaml +85 -0
  22. package/.github/CODE_OF_CONDUCT.md +128 -0
  23. package/.github/FUNDING.yaml +15 -0
  24. package/.github/ISSUE_TEMPLATE/bug-report.yaml +124 -0
  25. package/.github/ISSUE_TEMPLATE/config.yaml +8 -0
  26. package/.github/ISSUE_TEMPLATE/documentation.yaml +55 -0
  27. package/.github/ISSUE_TEMPLATE/feature-request.md +22 -0
  28. package/.github/ISSUE_TEMPLATE/issue.md +32 -0
  29. package/.github/PULL_REQUEST_TEMPLATE.md +13 -0
  30. package/.github/scripts/discord-helpers.sh +34 -0
  31. package/.github/workflows/coderabbit-review.yaml +22 -0
  32. package/.github/workflows/discord.yaml +90 -0
  33. package/.github/workflows/docs.yaml +64 -0
  34. package/.github/workflows/quality.yaml +116 -0
  35. package/.husky/pre-commit +20 -0
  36. package/.markdownlint-cli2.yaml +41 -0
  37. package/.nvmrc +1 -0
  38. package/.prettierignore +12 -0
  39. package/.vscode/settings.json +96 -0
  40. package/AGENTS.md +227 -165
  41. package/AGENTS_LIST.md +946 -0
  42. package/ARCHITECTURE.md +590 -0
  43. package/CHANGELOG.md +1770 -0
  44. package/CNAME +1 -0
  45. package/CONTRIBUTING.md +512 -0
  46. package/CONTRIBUTORS.md +32 -0
  47. package/INSTALL.md +246 -0
  48. package/LICENSE +30 -0
  49. package/README.md +133 -194
  50. package/RELEASE_NOTES.md +246 -0
  51. package/SECURITY.md +85 -0
  52. package/TRADEMARK.md +55 -0
  53. package/USAGE.md +368 -0
  54. package/Wordmark.png +0 -0
  55. package/app/__init__.py +5 -0
  56. package/app/cis/agents/__init__.py +31 -0
  57. package/app/cis/agents/brainstorming-coach/__init__.py +3 -0
  58. package/app/cis/agents/brainstorming-coach/agent.py +162 -0
  59. package/app/cis/agents/brainstorming-coach/prompt.yaml +53 -0
  60. package/app/cis/agents/creative-problem-solver/__init__.py +3 -0
  61. package/app/cis/agents/creative-problem-solver/agent.py +233 -0
  62. package/app/cis/agents/creative-problem-solver/prompt.yaml +74 -0
  63. package/app/cis/agents/design-thinking-coach/__init__.py +3 -0
  64. package/app/cis/agents/design-thinking-coach/agent.py +241 -0
  65. package/app/cis/agents/design-thinking-coach/prompt.yaml +77 -0
  66. package/app/cis/agents/innovation-strategist/__init__.py +3 -0
  67. package/app/cis/agents/innovation-strategist/agent.py +271 -0
  68. package/app/cis/agents/innovation-strategist/prompt.yaml +70 -0
  69. package/app/cis/agents/presentation-master/__init__.py +3 -0
  70. package/app/cis/agents/presentation-master/agent.py +420 -0
  71. package/app/cis/agents/presentation-master/prompt.yaml +62 -0
  72. package/app/cis/agents/storyteller/__init__.py +3 -0
  73. package/app/cis/agents/storyteller/agent.py +303 -0
  74. package/app/cis/agents/storyteller/prompt.yaml +99 -0
  75. package/app/core/__init__.py +5 -0
  76. package/app/core/agents/__init__.py +5 -0
  77. package/app/core/agents/mdan-master/__init__.py +7 -0
  78. package/app/core/agents/mdan-master/agent.py +302 -0
  79. package/app/core/agents/mdan-master/prompt.yaml +105 -0
  80. package/app/mmb/agents/__init__.py +24 -0
  81. package/app/mmb/agents/agent-builder/__init__.py +5 -0
  82. package/app/mmb/agents/agent-builder/agent.py +261 -0
  83. package/app/mmb/agents/agent-builder/prompt.yaml +48 -0
  84. package/app/mmb/agents/module-builder/__init__.py +5 -0
  85. package/app/mmb/agents/module-builder/agent.py +299 -0
  86. package/app/mmb/agents/module-builder/prompt.yaml +50 -0
  87. package/app/mmb/agents/workflow-builder/__init__.py +5 -0
  88. package/app/mmb/agents/workflow-builder/agent.py +318 -0
  89. package/app/mmb/agents/workflow-builder/prompt.yaml +52 -0
  90. package/app/mmm/agents/__init__.py +48 -0
  91. package/app/mmm/agents/analyst/__init__.py +7 -0
  92. package/app/mmm/agents/analyst/agent.py +384 -0
  93. package/app/mmm/agents/analyst/prompt.yaml +62 -0
  94. package/app/mmm/agents/architect/__init__.py +7 -0
  95. package/app/mmm/agents/architect/agent.py +300 -0
  96. package/app/mmm/agents/architect/prompt.yaml +66 -0
  97. package/app/mmm/agents/dev/__init__.py +7 -0
  98. package/app/mmm/agents/dev/agent.py +285 -0
  99. package/app/mmm/agents/dev/prompt.yaml +62 -0
  100. package/app/mmm/agents/pm/__init__.py +7 -0
  101. package/app/mmm/agents/pm/agent.py +417 -0
  102. package/app/mmm/agents/pm/prompt.yaml +64 -0
  103. package/app/mmm/agents/qa/__init__.py +7 -0
  104. package/app/mmm/agents/qa/agent.py +267 -0
  105. package/app/mmm/agents/qa/prompt.yaml +67 -0
  106. package/app/mmm/agents/quick-flow-solo-dev/__init__.py +7 -0
  107. package/app/mmm/agents/quick-flow-solo-dev/agent.py +319 -0
  108. package/app/mmm/agents/quick-flow-solo-dev/prompt.yaml +60 -0
  109. package/app/mmm/agents/sm/__init__.py +7 -0
  110. package/app/mmm/agents/sm/agent.py +357 -0
  111. package/app/mmm/agents/sm/prompt.yaml +61 -0
  112. package/app/mmm/agents/tech-writer/__init__.py +7 -0
  113. package/app/mmm/agents/tech-writer/agent.py +420 -0
  114. package/app/mmm/agents/tech-writer/prompt.yaml +70 -0
  115. package/app/mmm/agents/ux-designer/__init__.py +14 -0
  116. package/app/mmm/agents/ux-designer/agent.py +412 -0
  117. package/app/mmm/agents/ux-designer/prompt.yaml +37 -0
  118. package/app/packs/__init__.py +32 -0
  119. package/app/packs/db-optimization/__init__.py +13 -0
  120. package/app/packs/db-optimization/agents/__init__.py +11 -0
  121. package/app/packs/db-optimization/agents/db-performance-analyst/__init__.py +5 -0
  122. package/app/packs/db-optimization/agents/db-performance-analyst/agent.py +559 -0
  123. package/app/packs/db-optimization/agents/db-performance-analyst/prompt.yaml +63 -0
  124. package/app/packs/db-optimization/agents/indexing-specialist/__init__.py +5 -0
  125. package/app/packs/db-optimization/agents/indexing-specialist/agent.py +713 -0
  126. package/app/packs/db-optimization/agents/indexing-specialist/prompt.yaml +92 -0
  127. package/app/packs/db-optimization/agents/query-optimizer/__init__.py +5 -0
  128. package/app/packs/db-optimization/agents/query-optimizer/agent.py +566 -0
  129. package/app/packs/db-optimization/agents/query-optimizer/prompt.yaml +74 -0
  130. package/app/packs/devops-azure/__init__.py +13 -0
  131. package/app/packs/devops-azure/agents/__init__.py +11 -0
  132. package/app/packs/devops-azure/agents/azure-specialist/__init__.py +5 -0
  133. package/app/packs/devops-azure/agents/azure-specialist/agent.py +584 -0
  134. package/app/packs/devops-azure/agents/azure-specialist/prompt.yaml +301 -0
  135. package/app/packs/devops-azure/agents/cicd-architect/__init__.py +5 -0
  136. package/app/packs/devops-azure/agents/cicd-architect/agent.py +665 -0
  137. package/app/packs/devops-azure/agents/cicd-architect/prompt.yaml +409 -0
  138. package/app/packs/devops-azure/agents/devops-engineer/__init__.py +5 -0
  139. package/app/packs/devops-azure/agents/devops-engineer/agent.py +545 -0
  140. package/app/packs/devops-azure/agents/devops-engineer/prompt.yaml +263 -0
  141. package/app/packs/fintech/__init__.py +13 -0
  142. package/app/packs/fintech/agents/__init__.py +11 -0
  143. package/app/packs/fintech/agents/compliance-officer/__init__.py +5 -0
  144. package/app/packs/fintech/agents/compliance-officer/agent.py +449 -0
  145. package/app/packs/fintech/agents/compliance-officer/prompt.yaml +135 -0
  146. package/app/packs/fintech/agents/financial-analyst/__init__.py +5 -0
  147. package/app/packs/fintech/agents/financial-analyst/agent.py +392 -0
  148. package/app/packs/fintech/agents/financial-analyst/prompt.yaml +143 -0
  149. package/app/packs/fintech/agents/risk-manager/__init__.py +5 -0
  150. package/app/packs/fintech/agents/risk-manager/agent.py +664 -0
  151. package/app/packs/fintech/agents/risk-manager/prompt.yaml +240 -0
  152. package/app/tea/agents/tea/__init__.py +9 -0
  153. package/app/tea/agents/tea/agent.py +689 -0
  154. package/app/tea/agents/tea/prompt.yaml +100 -0
  155. package/banner-bmad-method.png +0 -0
  156. package/docs/404.md +9 -0
  157. package/docs/_STYLE_GUIDE.md +370 -0
  158. package/docs/explanation/advanced-elicitation.md +49 -0
  159. package/docs/explanation/adversarial-review.md +59 -0
  160. package/docs/explanation/brainstorming.md +33 -0
  161. package/docs/explanation/established-projects-faq.md +50 -0
  162. package/docs/explanation/party-mode.md +59 -0
  163. package/docs/explanation/preventing-agent-conflicts.md +112 -0
  164. package/docs/explanation/project-context.md +157 -0
  165. package/docs/explanation/quick-flow.md +73 -0
  166. package/docs/explanation/why-solutioning-matters.md +77 -0
  167. package/docs/how-to/customize-bmad.md +172 -0
  168. package/docs/how-to/established-projects.md +117 -0
  169. package/docs/how-to/get-answers-about-bmad.md +134 -0
  170. package/docs/how-to/install-bmad.md +97 -0
  171. package/docs/how-to/non-interactive-installation.md +171 -0
  172. package/docs/how-to/project-context.md +136 -0
  173. package/docs/how-to/quick-fixes.md +123 -0
  174. package/docs/how-to/shard-large-documents.md +78 -0
  175. package/docs/how-to/upgrade-to-v6.md +97 -0
  176. package/docs/index.md +59 -0
  177. package/docs/reference/agents.md +28 -0
  178. package/docs/reference/commands.md +151 -0
  179. package/docs/reference/modules.md +76 -0
  180. package/docs/reference/testing.md +106 -0
  181. package/docs/reference/workflow-map.md +89 -0
  182. package/docs/roadmap.mdx +136 -0
  183. package/docs/tutorials/getting-started.md +286 -0
  184. package/eslint.config.mjs +141 -0
  185. package/package.json +106 -37
  186. package/prettier.config.mjs +32 -0
  187. package/prompts/cis/brainstorming-coach.yaml +53 -0
  188. package/prompts/cis/creative-problem-solver.yaml +74 -0
  189. package/prompts/cis/design-thinking-coach.yaml +77 -0
  190. package/prompts/cis/innovation-strategist.yaml +70 -0
  191. package/prompts/cis/presentation-master.yaml +62 -0
  192. package/prompts/cis/storyteller.yaml +99 -0
  193. package/prompts/core/mdan-master.yaml +105 -0
  194. package/prompts/mmb/agent-builder.yaml +48 -0
  195. package/prompts/mmb/module-builder.yaml +50 -0
  196. package/prompts/mmb/workflow-builder.yaml +52 -0
  197. package/prompts/mmm/analyst.yaml +62 -0
  198. package/prompts/mmm/architect.yaml +66 -0
  199. package/prompts/mmm/dev.yaml +62 -0
  200. package/prompts/mmm/pm.yaml +64 -0
  201. package/prompts/mmm/qa.yaml +67 -0
  202. package/prompts/mmm/quick-flow-solo-dev.yaml +60 -0
  203. package/prompts/mmm/sm.yaml +61 -0
  204. package/prompts/mmm/tech-writer.yaml +70 -0
  205. package/prompts/mmm/ux-designer.yaml +33 -0
  206. package/prompts/packs/db-optimization/db-performance-analyst.yaml +63 -0
  207. package/prompts/packs/db-optimization/indexing-specialist.yaml +92 -0
  208. package/prompts/packs/db-optimization/query-optimizer.yaml +74 -0
  209. package/prompts/packs/devops-azure/azure-specialist.yaml +301 -0
  210. package/prompts/packs/devops-azure/cicd-architect.yaml +409 -0
  211. package/prompts/packs/devops-azure/devops-engineer.yaml +263 -0
  212. package/prompts/packs/fintech/compliance-officer.yaml +135 -0
  213. package/prompts/packs/fintech/financial-analyst.yaml +143 -0
  214. package/prompts/packs/fintech/risk-manager.yaml +240 -0
  215. package/prompts/tea/tea.yaml +100 -0
  216. package/prompts.json +237 -0
  217. package/src/bmm/agents/analyst.agent.yaml +43 -0
  218. package/src/bmm/agents/architect.agent.yaml +29 -0
  219. package/src/bmm/agents/dev.agent.yaml +38 -0
  220. package/src/bmm/agents/pm.agent.yaml +44 -0
  221. package/src/bmm/agents/qa.agent.yaml +58 -0
  222. package/src/bmm/agents/quick-flow-solo-dev.agent.yaml +32 -0
  223. package/src/bmm/agents/sm.agent.yaml +37 -0
  224. package/src/bmm/agents/tech-writer/tech-writer-sidecar/documentation-standards.md +224 -0
  225. package/src/bmm/agents/tech-writer/tech-writer.agent.yaml +46 -0
  226. package/src/bmm/agents/ux-designer.agent.yaml +27 -0
  227. package/src/bmm/data/project-context-template.md +26 -0
  228. package/src/bmm/module-help.csv +31 -0
  229. package/src/bmm/module.yaml +50 -0
  230. package/src/bmm/teams/default-party.csv +20 -0
  231. package/src/bmm/teams/team-fullstack.yaml +12 -0
  232. package/src/bmm/workflows/1-analysis/create-product-brief/product-brief.template.md +10 -0
  233. package/src/bmm/workflows/1-analysis/create-product-brief/steps/step-01-init.md +177 -0
  234. package/src/bmm/workflows/1-analysis/create-product-brief/steps/step-01b-continue.md +161 -0
  235. package/src/bmm/workflows/1-analysis/create-product-brief/steps/step-02-vision.md +199 -0
  236. package/src/bmm/workflows/1-analysis/create-product-brief/steps/step-03-users.md +202 -0
  237. package/src/bmm/workflows/1-analysis/create-product-brief/steps/step-04-metrics.md +205 -0
  238. package/src/bmm/workflows/1-analysis/create-product-brief/steps/step-05-scope.md +219 -0
  239. package/src/bmm/workflows/1-analysis/create-product-brief/steps/step-06-complete.md +162 -0
  240. package/src/bmm/workflows/1-analysis/create-product-brief/workflow.md +57 -0
  241. package/src/bmm/workflows/1-analysis/research/domain-steps/step-01-init.md +137 -0
  242. package/src/bmm/workflows/1-analysis/research/domain-steps/step-02-domain-analysis.md +229 -0
  243. package/src/bmm/workflows/1-analysis/research/domain-steps/step-03-competitive-landscape.md +238 -0
  244. package/src/bmm/workflows/1-analysis/research/domain-steps/step-04-regulatory-focus.md +206 -0
  245. package/src/bmm/workflows/1-analysis/research/domain-steps/step-05-technical-trends.md +234 -0
  246. package/src/bmm/workflows/1-analysis/research/domain-steps/step-06-research-synthesis.md +444 -0
  247. package/src/bmm/workflows/1-analysis/research/market-steps/step-01-init.md +182 -0
  248. package/src/bmm/workflows/1-analysis/research/market-steps/step-02-customer-behavior.md +237 -0
  249. package/src/bmm/workflows/1-analysis/research/market-steps/step-03-customer-pain-points.md +249 -0
  250. package/src/bmm/workflows/1-analysis/research/market-steps/step-04-customer-decisions.md +259 -0
  251. package/src/bmm/workflows/1-analysis/research/market-steps/step-05-competitive-analysis.md +177 -0
  252. package/src/bmm/workflows/1-analysis/research/market-steps/step-06-research-completion.md +476 -0
  253. package/src/bmm/workflows/1-analysis/research/research.template.md +29 -0
  254. package/src/bmm/workflows/1-analysis/research/technical-steps/step-01-init.md +137 -0
  255. package/src/bmm/workflows/1-analysis/research/technical-steps/step-02-technical-overview.md +239 -0
  256. package/src/bmm/workflows/1-analysis/research/technical-steps/step-03-integration-patterns.md +248 -0
  257. package/src/bmm/workflows/1-analysis/research/technical-steps/step-04-architectural-patterns.md +202 -0
  258. package/src/bmm/workflows/1-analysis/research/technical-steps/step-05-implementation-research.md +233 -0
  259. package/src/bmm/workflows/1-analysis/research/technical-steps/step-06-research-synthesis.md +487 -0
  260. package/src/bmm/workflows/1-analysis/research/workflow-domain-research.md +54 -0
  261. package/src/bmm/workflows/1-analysis/research/workflow-market-research.md +54 -0
  262. package/src/bmm/workflows/1-analysis/research/workflow-technical-research.md +54 -0
  263. package/src/bmm/workflows/2-plan-workflows/create-prd/data/domain-complexity.csv +15 -0
  264. package/src/bmm/workflows/2-plan-workflows/create-prd/data/prd-purpose.md +197 -0
  265. package/src/bmm/workflows/2-plan-workflows/create-prd/data/project-types.csv +11 -0
  266. package/src/bmm/workflows/2-plan-workflows/create-prd/steps-c/step-01-init.md +191 -0
  267. package/src/bmm/workflows/2-plan-workflows/create-prd/steps-c/step-01b-continue.md +152 -0
  268. package/src/bmm/workflows/2-plan-workflows/create-prd/steps-c/step-02-discovery.md +224 -0
  269. package/src/bmm/workflows/2-plan-workflows/create-prd/steps-c/step-02b-vision.md +154 -0
  270. package/src/bmm/workflows/2-plan-workflows/create-prd/steps-c/step-02c-executive-summary.md +170 -0
  271. package/src/bmm/workflows/2-plan-workflows/create-prd/steps-c/step-03-success.md +226 -0
  272. package/src/bmm/workflows/2-plan-workflows/create-prd/steps-c/step-04-journeys.md +213 -0
  273. package/src/bmm/workflows/2-plan-workflows/create-prd/steps-c/step-05-domain.md +207 -0
  274. package/src/bmm/workflows/2-plan-workflows/create-prd/steps-c/step-06-innovation.md +226 -0
  275. package/src/bmm/workflows/2-plan-workflows/create-prd/steps-c/step-07-project-type.md +237 -0
  276. package/src/bmm/workflows/2-plan-workflows/create-prd/steps-c/step-08-scoping.md +228 -0
  277. package/src/bmm/workflows/2-plan-workflows/create-prd/steps-c/step-09-functional.md +231 -0
  278. package/src/bmm/workflows/2-plan-workflows/create-prd/steps-c/step-10-nonfunctional.md +242 -0
  279. package/src/bmm/workflows/2-plan-workflows/create-prd/steps-c/step-11-polish.md +217 -0
  280. package/src/bmm/workflows/2-plan-workflows/create-prd/steps-c/step-12-complete.md +124 -0
  281. package/src/bmm/workflows/2-plan-workflows/create-prd/steps-e/step-e-01-discovery.md +247 -0
  282. package/src/bmm/workflows/2-plan-workflows/create-prd/steps-e/step-e-01b-legacy-conversion.md +208 -0
  283. package/src/bmm/workflows/2-plan-workflows/create-prd/steps-e/step-e-02-review.md +249 -0
  284. package/src/bmm/workflows/2-plan-workflows/create-prd/steps-e/step-e-03-edit.md +253 -0
  285. package/src/bmm/workflows/2-plan-workflows/create-prd/steps-e/step-e-04-complete.md +168 -0
  286. package/src/bmm/workflows/2-plan-workflows/create-prd/steps-v/step-v-01-discovery.md +226 -0
  287. package/src/bmm/workflows/2-plan-workflows/create-prd/steps-v/step-v-02-format-detection.md +191 -0
  288. package/src/bmm/workflows/2-plan-workflows/create-prd/steps-v/step-v-02b-parity-check.md +209 -0
  289. package/src/bmm/workflows/2-plan-workflows/create-prd/steps-v/step-v-03-density-validation.md +174 -0
  290. package/src/bmm/workflows/2-plan-workflows/create-prd/steps-v/step-v-04-brief-coverage-validation.md +214 -0
  291. package/src/bmm/workflows/2-plan-workflows/create-prd/steps-v/step-v-05-measurability-validation.md +228 -0
  292. package/src/bmm/workflows/2-plan-workflows/create-prd/steps-v/step-v-06-traceability-validation.md +217 -0
  293. package/src/bmm/workflows/2-plan-workflows/create-prd/steps-v/step-v-07-implementation-leakage-validation.md +205 -0
  294. package/src/bmm/workflows/2-plan-workflows/create-prd/steps-v/step-v-08-domain-compliance-validation.md +243 -0
  295. package/src/bmm/workflows/2-plan-workflows/create-prd/steps-v/step-v-09-project-type-validation.md +263 -0
  296. package/src/bmm/workflows/2-plan-workflows/create-prd/steps-v/step-v-10-smart-validation.md +209 -0
  297. package/src/bmm/workflows/2-plan-workflows/create-prd/steps-v/step-v-11-holistic-quality-validation.md +264 -0
  298. package/src/bmm/workflows/2-plan-workflows/create-prd/steps-v/step-v-12-completeness-validation.md +242 -0
  299. package/src/bmm/workflows/2-plan-workflows/create-prd/steps-v/step-v-13-report-complete.md +231 -0
  300. package/src/bmm/workflows/2-plan-workflows/create-prd/templates/prd-template.md +10 -0
  301. package/src/bmm/workflows/2-plan-workflows/create-prd/workflow-create-prd.md +63 -0
  302. package/src/bmm/workflows/2-plan-workflows/create-prd/workflow-edit-prd.md +65 -0
  303. package/src/bmm/workflows/2-plan-workflows/create-prd/workflow-validate-prd.md +63 -0
  304. package/src/bmm/workflows/2-plan-workflows/create-ux-design/steps/step-01-init.md +135 -0
  305. package/src/bmm/workflows/2-plan-workflows/create-ux-design/steps/step-01b-continue.md +127 -0
  306. package/src/bmm/workflows/2-plan-workflows/create-ux-design/steps/step-02-discovery.md +190 -0
  307. package/src/bmm/workflows/2-plan-workflows/create-ux-design/steps/step-03-core-experience.md +216 -0
  308. package/src/bmm/workflows/2-plan-workflows/create-ux-design/steps/step-04-emotional-response.md +219 -0
  309. package/src/bmm/workflows/2-plan-workflows/create-ux-design/steps/step-05-inspiration.md +234 -0
  310. package/src/bmm/workflows/2-plan-workflows/create-ux-design/steps/step-06-design-system.md +252 -0
  311. package/src/bmm/workflows/2-plan-workflows/create-ux-design/steps/step-07-defining-experience.md +254 -0
  312. package/src/bmm/workflows/2-plan-workflows/create-ux-design/steps/step-08-visual-foundation.md +224 -0
  313. package/src/bmm/workflows/2-plan-workflows/create-ux-design/steps/step-09-design-directions.md +224 -0
  314. package/src/bmm/workflows/2-plan-workflows/create-ux-design/steps/step-10-user-journeys.md +241 -0
  315. package/src/bmm/workflows/2-plan-workflows/create-ux-design/steps/step-11-component-strategy.md +248 -0
  316. package/src/bmm/workflows/2-plan-workflows/create-ux-design/steps/step-12-ux-patterns.md +237 -0
  317. package/src/bmm/workflows/2-plan-workflows/create-ux-design/steps/step-13-responsive-accessibility.md +264 -0
  318. package/src/bmm/workflows/2-plan-workflows/create-ux-design/steps/step-14-complete.md +171 -0
  319. package/src/bmm/workflows/2-plan-workflows/create-ux-design/ux-design-template.md +13 -0
  320. package/src/bmm/workflows/2-plan-workflows/create-ux-design/workflow.md +42 -0
  321. package/src/bmm/workflows/3-solutioning/check-implementation-readiness/steps/step-01-document-discovery.md +184 -0
  322. package/src/bmm/workflows/3-solutioning/check-implementation-readiness/steps/step-02-prd-analysis.md +172 -0
  323. package/src/bmm/workflows/3-solutioning/check-implementation-readiness/steps/step-03-epic-coverage-validation.md +173 -0
  324. package/src/bmm/workflows/3-solutioning/check-implementation-readiness/steps/step-04-ux-alignment.md +133 -0
  325. package/src/bmm/workflows/3-solutioning/check-implementation-readiness/steps/step-05-epic-quality-review.md +245 -0
  326. package/src/bmm/workflows/3-solutioning/check-implementation-readiness/steps/step-06-final-assessment.md +129 -0
  327. package/src/bmm/workflows/3-solutioning/check-implementation-readiness/templates/readiness-report-template.md +4 -0
  328. package/src/bmm/workflows/3-solutioning/check-implementation-readiness/workflow.md +54 -0
  329. package/src/bmm/workflows/3-solutioning/create-architecture/architecture-decision-template.md +12 -0
  330. package/src/bmm/workflows/3-solutioning/create-architecture/data/domain-complexity.csv +13 -0
  331. package/src/bmm/workflows/3-solutioning/create-architecture/data/project-types.csv +7 -0
  332. package/src/bmm/workflows/3-solutioning/create-architecture/steps/step-01-init.md +153 -0
  333. package/src/bmm/workflows/3-solutioning/create-architecture/steps/step-01b-continue.md +173 -0
  334. package/src/bmm/workflows/3-solutioning/create-architecture/steps/step-02-context.md +224 -0
  335. package/src/bmm/workflows/3-solutioning/create-architecture/steps/step-03-starter.md +329 -0
  336. package/src/bmm/workflows/3-solutioning/create-architecture/steps/step-04-decisions.md +318 -0
  337. package/src/bmm/workflows/3-solutioning/create-architecture/steps/step-05-patterns.md +359 -0
  338. package/src/bmm/workflows/3-solutioning/create-architecture/steps/step-06-structure.md +379 -0
  339. package/src/bmm/workflows/3-solutioning/create-architecture/steps/step-07-validation.md +359 -0
  340. package/src/bmm/workflows/3-solutioning/create-architecture/steps/step-08-complete.md +76 -0
  341. package/src/bmm/workflows/3-solutioning/create-architecture/workflow.md +49 -0
  342. package/src/bmm/workflows/3-solutioning/create-epics-and-stories/steps/step-01-validate-prerequisites.md +259 -0
  343. package/src/bmm/workflows/3-solutioning/create-epics-and-stories/steps/step-02-design-epics.md +233 -0
  344. package/src/bmm/workflows/3-solutioning/create-epics-and-stories/steps/step-03-create-stories.md +272 -0
  345. package/src/bmm/workflows/3-solutioning/create-epics-and-stories/steps/step-04-final-validation.md +149 -0
  346. package/src/bmm/workflows/3-solutioning/create-epics-and-stories/templates/epics-template.md +57 -0
  347. package/src/bmm/workflows/3-solutioning/create-epics-and-stories/workflow.md +58 -0
  348. package/src/bmm/workflows/4-implementation/code-review/checklist.md +23 -0
  349. package/src/bmm/workflows/4-implementation/code-review/instructions.xml +227 -0
  350. package/src/bmm/workflows/4-implementation/code-review/workflow.yaml +43 -0
  351. package/src/bmm/workflows/4-implementation/correct-course/checklist.md +288 -0
  352. package/src/bmm/workflows/4-implementation/correct-course/instructions.md +207 -0
  353. package/src/bmm/workflows/4-implementation/correct-course/workflow.yaml +53 -0
  354. package/src/bmm/workflows/4-implementation/create-story/checklist.md +358 -0
  355. package/src/bmm/workflows/4-implementation/create-story/instructions.xml +346 -0
  356. package/src/bmm/workflows/4-implementation/create-story/template.md +49 -0
  357. package/src/bmm/workflows/4-implementation/create-story/workflow.yaml +52 -0
  358. package/src/bmm/workflows/4-implementation/dev-story/checklist.md +80 -0
  359. package/src/bmm/workflows/4-implementation/dev-story/instructions.xml +410 -0
  360. package/src/bmm/workflows/4-implementation/dev-story/workflow.yaml +20 -0
  361. package/src/bmm/workflows/4-implementation/retrospective/instructions.md +1444 -0
  362. package/src/bmm/workflows/4-implementation/retrospective/workflow.yaml +52 -0
  363. package/src/bmm/workflows/4-implementation/sprint-planning/checklist.md +33 -0
  364. package/src/bmm/workflows/4-implementation/sprint-planning/instructions.md +226 -0
  365. package/src/bmm/workflows/4-implementation/sprint-planning/sprint-status-template.yaml +55 -0
  366. package/src/bmm/workflows/4-implementation/sprint-planning/workflow.yaml +47 -0
  367. package/src/bmm/workflows/4-implementation/sprint-status/instructions.md +230 -0
  368. package/src/bmm/workflows/4-implementation/sprint-status/workflow.yaml +25 -0
  369. package/src/bmm/workflows/bmad-quick-flow/quick-dev/steps/step-01-mode-detection.md +174 -0
  370. package/src/bmm/workflows/bmad-quick-flow/quick-dev/steps/step-02-context-gathering.md +118 -0
  371. package/src/bmm/workflows/bmad-quick-flow/quick-dev/steps/step-03-execute.md +111 -0
  372. package/src/bmm/workflows/bmad-quick-flow/quick-dev/steps/step-04-self-check.md +111 -0
  373. package/src/bmm/workflows/bmad-quick-flow/quick-dev/steps/step-05-adversarial-review.md +104 -0
  374. package/src/bmm/workflows/bmad-quick-flow/quick-dev/steps/step-06-resolve-findings.md +146 -0
  375. package/src/bmm/workflows/bmad-quick-flow/quick-dev/workflow.md +50 -0
  376. package/src/bmm/workflows/bmad-quick-flow/quick-spec/steps/step-01-understand.md +189 -0
  377. package/src/bmm/workflows/bmad-quick-flow/quick-spec/steps/step-02-investigate.md +143 -0
  378. package/src/bmm/workflows/bmad-quick-flow/quick-spec/steps/step-03-generate.md +126 -0
  379. package/src/bmm/workflows/bmad-quick-flow/quick-spec/steps/step-04-review.md +200 -0
  380. package/src/bmm/workflows/bmad-quick-flow/quick-spec/tech-spec-template.md +74 -0
  381. package/src/bmm/workflows/bmad-quick-flow/quick-spec/workflow.md +79 -0
  382. package/src/bmm/workflows/document-project/checklist.md +245 -0
  383. package/src/bmm/workflows/document-project/documentation-requirements.csv +12 -0
  384. package/src/bmm/workflows/document-project/instructions.md +130 -0
  385. package/src/bmm/workflows/document-project/templates/deep-dive-template.md +345 -0
  386. package/src/bmm/workflows/document-project/templates/index-template.md +169 -0
  387. package/src/bmm/workflows/document-project/templates/project-overview-template.md +103 -0
  388. package/src/bmm/workflows/document-project/templates/project-scan-report-schema.json +160 -0
  389. package/src/bmm/workflows/document-project/templates/source-tree-template.md +135 -0
  390. package/src/bmm/workflows/document-project/workflow.yaml +22 -0
  391. package/src/bmm/workflows/document-project/workflows/deep-dive-instructions.md +298 -0
  392. package/src/bmm/workflows/document-project/workflows/deep-dive.yaml +31 -0
  393. package/src/bmm/workflows/document-project/workflows/full-scan-instructions.md +1106 -0
  394. package/src/bmm/workflows/document-project/workflows/full-scan.yaml +31 -0
  395. package/src/bmm/workflows/generate-project-context/project-context-template.md +21 -0
  396. package/src/bmm/workflows/generate-project-context/steps/step-01-discover.md +184 -0
  397. package/src/bmm/workflows/generate-project-context/steps/step-02-generate.md +318 -0
  398. package/src/bmm/workflows/generate-project-context/steps/step-03-complete.md +278 -0
  399. package/src/bmm/workflows/generate-project-context/workflow.md +49 -0
  400. package/src/bmm/workflows/qa-generate-e2e-tests/checklist.md +33 -0
  401. package/src/bmm/workflows/qa-generate-e2e-tests/instructions.md +110 -0
  402. package/src/bmm/workflows/qa-generate-e2e-tests/workflow.yaml +42 -0
  403. package/src/core/agents/bmad-master.agent.yaml +30 -0
  404. package/src/core/module-help.csv +9 -0
  405. package/src/core/module.yaml +25 -0
  406. package/src/core/tasks/editorial-review-prose.xml +102 -0
  407. package/src/core/tasks/editorial-review-structure.xml +208 -0
  408. package/src/core/tasks/help.md +86 -0
  409. package/src/core/tasks/index-docs.xml +65 -0
  410. package/src/core/tasks/review-adversarial-general.xml +49 -0
  411. package/src/core/tasks/shard-doc.xml +108 -0
  412. package/src/core/tasks/workflow.xml +235 -0
  413. package/src/core/workflows/advanced-elicitation/methods.csv +51 -0
  414. package/src/core/workflows/advanced-elicitation/workflow.xml +118 -0
  415. package/src/core/workflows/brainstorming/brain-methods.csv +62 -0
  416. package/src/core/workflows/brainstorming/steps/step-01-session-setup.md +197 -0
  417. package/src/core/workflows/brainstorming/steps/step-01b-continue.md +122 -0
  418. package/src/core/workflows/brainstorming/steps/step-02a-user-selected.md +225 -0
  419. package/src/core/workflows/brainstorming/steps/step-02b-ai-recommended.md +237 -0
  420. package/src/core/workflows/brainstorming/steps/step-02c-random-selection.md +209 -0
  421. package/src/core/workflows/brainstorming/steps/step-02d-progressive-flow.md +264 -0
  422. package/src/core/workflows/brainstorming/steps/step-03-technique-execution.md +399 -0
  423. package/src/core/workflows/brainstorming/steps/step-04-idea-organization.md +303 -0
  424. package/src/core/workflows/brainstorming/template.md +15 -0
  425. package/src/core/workflows/brainstorming/workflow.md +58 -0
  426. package/src/core/workflows/party-mode/steps/step-01-agent-loading.md +138 -0
  427. package/src/core/workflows/party-mode/steps/step-02-discussion-orchestration.md +187 -0
  428. package/src/core/workflows/party-mode/steps/step-03-graceful-exit.md +168 -0
  429. package/src/core/workflows/party-mode/workflow.md +194 -0
  430. package/src/utility/agent-components/activation-rules.txt +6 -0
  431. package/src/utility/agent-components/activation-steps.txt +14 -0
  432. package/src/utility/agent-components/agent-command-header.md +1 -0
  433. package/src/utility/agent-components/agent.customize.template.yaml +41 -0
  434. package/src/utility/agent-components/handler-action.txt +4 -0
  435. package/src/utility/agent-components/handler-data.txt +5 -0
  436. package/src/utility/agent-components/handler-exec.txt +6 -0
  437. package/src/utility/agent-components/handler-multi.txt +14 -0
  438. package/src/utility/agent-components/handler-tmpl.txt +5 -0
  439. package/src/utility/agent-components/handler-validate-workflow.txt +7 -0
  440. package/src/utility/agent-components/handler-workflow.txt +10 -0
  441. package/src/utility/agent-components/menu-handlers.txt +6 -0
  442. package/test/README.md +295 -0
  443. package/test/adversarial-review-tests/README.md +56 -0
  444. package/test/adversarial-review-tests/sample-content.md +46 -0
  445. package/test/adversarial-review-tests/test-cases.yaml +103 -0
  446. package/test/fixtures/agent-schema/invalid/critical-actions/actions-as-string.agent.yaml +27 -0
  447. package/test/fixtures/agent-schema/invalid/critical-actions/empty-string-in-actions.agent.yaml +30 -0
  448. package/test/fixtures/agent-schema/invalid/menu/empty-menu.agent.yaml +22 -0
  449. package/test/fixtures/agent-schema/invalid/menu/missing-menu.agent.yaml +20 -0
  450. package/test/fixtures/agent-schema/invalid/menu-commands/empty-command-target.agent.yaml +25 -0
  451. package/test/fixtures/agent-schema/invalid/menu-commands/no-command-target.agent.yaml +24 -0
  452. package/test/fixtures/agent-schema/invalid/menu-triggers/camel-case.agent.yaml +25 -0
  453. package/test/fixtures/agent-schema/invalid/menu-triggers/compound-invalid-format.agent.yaml +25 -0
  454. package/test/fixtures/agent-schema/invalid/menu-triggers/compound-mismatched-kebab.agent.yaml +25 -0
  455. package/test/fixtures/agent-schema/invalid/menu-triggers/duplicate-triggers.agent.yaml +31 -0
  456. package/test/fixtures/agent-schema/invalid/menu-triggers/empty-trigger.agent.yaml +25 -0
  457. package/test/fixtures/agent-schema/invalid/menu-triggers/leading-asterisk.agent.yaml +25 -0
  458. package/test/fixtures/agent-schema/invalid/menu-triggers/snake-case.agent.yaml +25 -0
  459. package/test/fixtures/agent-schema/invalid/menu-triggers/trigger-with-spaces.agent.yaml +25 -0
  460. package/test/fixtures/agent-schema/invalid/metadata/empty-module-string.agent.yaml +26 -0
  461. package/test/fixtures/agent-schema/invalid/metadata/empty-name.agent.yaml +24 -0
  462. package/test/fixtures/agent-schema/invalid/metadata/extra-metadata-fields.agent.yaml +27 -0
  463. package/test/fixtures/agent-schema/invalid/metadata/missing-id.agent.yaml +23 -0
  464. package/test/fixtures/agent-schema/invalid/persona/empty-principles-array.agent.yaml +24 -0
  465. package/test/fixtures/agent-schema/invalid/persona/empty-string-in-principles.agent.yaml +27 -0
  466. package/test/fixtures/agent-schema/invalid/persona/extra-persona-fields.agent.yaml +27 -0
  467. package/test/fixtures/agent-schema/invalid/persona/missing-role.agent.yaml +24 -0
  468. package/test/fixtures/agent-schema/invalid/prompts/empty-content.agent.yaml +29 -0
  469. package/test/fixtures/agent-schema/invalid/prompts/extra-prompt-fields.agent.yaml +31 -0
  470. package/test/fixtures/agent-schema/invalid/prompts/missing-content.agent.yaml +28 -0
  471. package/test/fixtures/agent-schema/invalid/prompts/missing-id.agent.yaml +28 -0
  472. package/test/fixtures/agent-schema/invalid/top-level/empty-file.agent.yaml +5 -0
  473. package/test/fixtures/agent-schema/invalid/top-level/extra-top-level-keys.agent.yaml +28 -0
  474. package/test/fixtures/agent-schema/invalid/top-level/missing-agent-key.agent.yaml +11 -0
  475. package/test/fixtures/agent-schema/invalid/yaml-errors/invalid-indentation.agent.yaml +19 -0
  476. package/test/fixtures/agent-schema/invalid/yaml-errors/malformed-yaml.agent.yaml +18 -0
  477. package/test/fixtures/agent-schema/valid/critical-actions/empty-critical-actions.agent.yaml +24 -0
  478. package/test/fixtures/agent-schema/valid/critical-actions/no-critical-actions.agent.yaml +22 -0
  479. package/test/fixtures/agent-schema/valid/critical-actions/valid-critical-actions.agent.yaml +27 -0
  480. package/test/fixtures/agent-schema/valid/menu/multiple-menu-items.agent.yaml +31 -0
  481. package/test/fixtures/agent-schema/valid/menu/single-menu-item.agent.yaml +22 -0
  482. package/test/fixtures/agent-schema/valid/menu-commands/all-command-types.agent.yaml +38 -0
  483. package/test/fixtures/agent-schema/valid/menu-commands/multiple-commands.agent.yaml +24 -0
  484. package/test/fixtures/agent-schema/valid/menu-triggers/compound-triggers.agent.yaml +31 -0
  485. package/test/fixtures/agent-schema/valid/menu-triggers/kebab-case-triggers.agent.yaml +34 -0
  486. package/test/fixtures/agent-schema/valid/metadata/core-agent-with-module.agent.yaml +24 -0
  487. package/test/fixtures/agent-schema/valid/metadata/empty-module-name-in-path.agent.yaml +24 -0
  488. package/test/fixtures/agent-schema/valid/metadata/malformed-path-treated-as-core.agent.yaml +24 -0
  489. package/test/fixtures/agent-schema/valid/metadata/module-agent-correct.agent.yaml +24 -0
  490. package/test/fixtures/agent-schema/valid/metadata/module-agent-missing-module.agent.yaml +23 -0
  491. package/test/fixtures/agent-schema/valid/metadata/wrong-module-value.agent.yaml +24 -0
  492. package/test/fixtures/agent-schema/valid/persona/complete-persona.agent.yaml +24 -0
  493. package/test/fixtures/agent-schema/valid/prompts/empty-prompts.agent.yaml +24 -0
  494. package/test/fixtures/agent-schema/valid/prompts/no-prompts.agent.yaml +22 -0
  495. package/test/fixtures/agent-schema/valid/prompts/valid-prompts-minimal.agent.yaml +28 -0
  496. package/test/fixtures/agent-schema/valid/prompts/valid-prompts-with-description.agent.yaml +30 -0
  497. package/test/fixtures/agent-schema/valid/top-level/minimal-core-agent.agent.yaml +24 -0
  498. package/test/fixtures/file-refs-csv/invalid/all-empty-workflow.csv +3 -0
  499. package/test/fixtures/file-refs-csv/invalid/empty-data.csv +1 -0
  500. package/test/fixtures/file-refs-csv/invalid/no-workflow-column.csv +3 -0
  501. package/test/fixtures/file-refs-csv/invalid/unresolvable-vars.csv +3 -0
  502. package/test/fixtures/file-refs-csv/valid/bmm-style.csv +3 -0
  503. package/test/fixtures/file-refs-csv/valid/core-style.csv +3 -0
  504. package/test/fixtures/file-refs-csv/valid/minimal.csv +2 -0
  505. package/test/test-agent-schema.js +387 -0
  506. package/test/test-cli-integration.sh +159 -0
  507. package/test/test-file-refs-csv.js +133 -0
  508. package/test/test-installation-components.js +212 -0
  509. package/test/test-rehype-plugins.mjs +1050 -0
  510. package/test/unit-test-schema.js +133 -0
  511. package/tests/run_all_tests.py +80 -0
  512. package/tests/scenarios/cis/brainstorming-coach.test.py +150 -0
  513. package/tests/scenarios/cis/creative-problem-solver.test.py +167 -0
  514. package/tests/scenarios/cis/design-thinking-coach.test.py +177 -0
  515. package/tests/scenarios/cis/innovation-strategist.test.py +191 -0
  516. package/tests/scenarios/cis/presentation-master.test.py +240 -0
  517. package/tests/scenarios/cis/storyteller.test.py +324 -0
  518. package/tests/scenarios/core/mdan-master.test.py +281 -0
  519. package/tests/scenarios/mmb/agent-builder.test.py +124 -0
  520. package/tests/scenarios/mmb/module-builder.test.py +124 -0
  521. package/tests/scenarios/mmb/workflow-builder.test.py +124 -0
  522. package/tests/scenarios/mmm/analyst.test.py +138 -0
  523. package/tests/scenarios/mmm/architect.test.py +138 -0
  524. package/tests/scenarios/mmm/dev.test.py +138 -0
  525. package/tests/scenarios/mmm/pm.test.py +138 -0
  526. package/tests/scenarios/mmm/qa.test.py +138 -0
  527. package/tests/scenarios/mmm/quick-flow-solo-dev.test.py +138 -0
  528. package/tests/scenarios/mmm/sm.test.py +138 -0
  529. package/tests/scenarios/mmm/tech-writer.test.py +138 -0
  530. package/tests/scenarios/mmm/ux-designer.test.py +294 -0
  531. package/tests/scenarios/packs/db-optimization/db-performance-analyst.test.py +108 -0
  532. package/tests/scenarios/packs/db-optimization/indexing-specialist.test.py +108 -0
  533. package/tests/scenarios/packs/db-optimization/query-optimizer.test.py +106 -0
  534. package/tests/scenarios/packs/devops-azure/azure-specialist.test.py +125 -0
  535. package/tests/scenarios/packs/devops-azure/cicd-architect.test.py +122 -0
  536. package/tests/scenarios/packs/devops-azure/devops-engineer.test.py +128 -0
  537. package/tests/scenarios/packs/fintech/compliance-officer.test.py +165 -0
  538. package/tests/scenarios/packs/fintech/financial-analyst.test.py +184 -0
  539. package/tests/scenarios/packs/fintech/risk-manager.test.py +171 -0
  540. package/tests/scenarios/tea/tea.test.py +346 -0
  541. package/tests/simple_cis_test.py +285 -0
  542. package/tests/simple_db_optimization_test.py +199 -0
  543. package/tests/simple_devops_test.py +193 -0
  544. package/tests/simple_fintech_test.py +205 -0
  545. package/tests/simple_mmb_test.py +103 -0
  546. package/tests/simple_mmm_test.py +159 -0
  547. package/tests/simple_tea_test.py +80 -0
  548. package/tests/simple_test.py +111 -0
  549. package/tests/simple_ux_designer_test.py +144 -0
  550. package/tests/validate_yaml.py +86 -0
  551. package/tools/bmad-npx-wrapper.js +38 -0
  552. package/tools/build-docs.mjs +463 -0
  553. package/tools/cli/README.md +60 -0
  554. package/tools/cli/bmad-cli.js +106 -0
  555. package/tools/cli/commands/install.js +87 -0
  556. package/tools/cli/commands/status.js +65 -0
  557. package/tools/cli/commands/uninstall.js +167 -0
  558. package/tools/cli/external-official-modules.yaml +53 -0
  559. package/tools/cli/installers/install-messages.yaml +39 -0
  560. package/tools/cli/installers/lib/core/config-collector.js +1285 -0
  561. package/tools/cli/installers/lib/core/custom-module-cache.js +260 -0
  562. package/tools/cli/installers/lib/core/dependency-resolver.js +743 -0
  563. package/tools/cli/installers/lib/core/detector.js +223 -0
  564. package/tools/cli/installers/lib/core/ide-config-manager.js +157 -0
  565. package/tools/cli/installers/lib/core/installer.js +3162 -0
  566. package/tools/cli/installers/lib/core/manifest-generator.js +1081 -0
  567. package/tools/cli/installers/lib/core/manifest.js +1038 -0
  568. package/tools/cli/installers/lib/custom/handler.js +358 -0
  569. package/tools/cli/installers/lib/ide/_base-ide.js +665 -0
  570. package/tools/cli/installers/lib/ide/_config-driven.js +634 -0
  571. package/tools/cli/installers/lib/ide/codex.js +440 -0
  572. package/tools/cli/installers/lib/ide/github-copilot.js +699 -0
  573. package/tools/cli/installers/lib/ide/kilo.js +269 -0
  574. package/tools/cli/installers/lib/ide/manager.js +342 -0
  575. package/tools/cli/installers/lib/ide/platform-codes.js +100 -0
  576. package/tools/cli/installers/lib/ide/platform-codes.yaml +243 -0
  577. package/tools/cli/installers/lib/ide/rovodev.js +257 -0
  578. package/tools/cli/installers/lib/ide/shared/agent-command-generator.js +180 -0
  579. package/tools/cli/installers/lib/ide/shared/bmad-artifacts.js +174 -0
  580. package/tools/cli/installers/lib/ide/shared/module-injections.js +136 -0
  581. package/tools/cli/installers/lib/ide/shared/path-utils.js +299 -0
  582. package/tools/cli/installers/lib/ide/shared/task-tool-command-generator.js +366 -0
  583. package/tools/cli/installers/lib/ide/shared/workflow-command-generator.js +318 -0
  584. package/tools/cli/installers/lib/ide/templates/agent-command-template.md +14 -0
  585. package/tools/cli/installers/lib/ide/templates/combined/antigravity.md +8 -0
  586. package/tools/cli/installers/lib/ide/templates/combined/default-agent.md +15 -0
  587. package/tools/cli/installers/lib/ide/templates/combined/default-task.md +10 -0
  588. package/tools/cli/installers/lib/ide/templates/combined/default-tool.md +10 -0
  589. package/tools/cli/installers/lib/ide/templates/combined/default-workflow-yaml.md +14 -0
  590. package/tools/cli/installers/lib/ide/templates/combined/default-workflow.md +6 -0
  591. package/tools/cli/installers/lib/ide/templates/combined/gemini-agent.toml +14 -0
  592. package/tools/cli/installers/lib/ide/templates/combined/gemini-task.toml +11 -0
  593. package/tools/cli/installers/lib/ide/templates/combined/gemini-tool.toml +11 -0
  594. package/tools/cli/installers/lib/ide/templates/combined/gemini-workflow-yaml.toml +16 -0
  595. package/tools/cli/installers/lib/ide/templates/combined/gemini-workflow.toml +14 -0
  596. package/tools/cli/installers/lib/ide/templates/combined/kiro-agent.md +16 -0
  597. package/tools/cli/installers/lib/ide/templates/combined/kiro-task.md +9 -0
  598. package/tools/cli/installers/lib/ide/templates/combined/kiro-tool.md +9 -0
  599. package/tools/cli/installers/lib/ide/templates/combined/kiro-workflow-yaml.md +15 -0
  600. package/tools/cli/installers/lib/ide/templates/combined/kiro-workflow.md +7 -0
  601. package/tools/cli/installers/lib/ide/templates/combined/opencode-agent.md +15 -0
  602. package/tools/cli/installers/lib/ide/templates/combined/opencode-task.md +13 -0
  603. package/tools/cli/installers/lib/ide/templates/combined/opencode-tool.md +13 -0
  604. package/tools/cli/installers/lib/ide/templates/combined/opencode-workflow-yaml.md +16 -0
  605. package/tools/cli/installers/lib/ide/templates/combined/opencode-workflow.md +16 -0
  606. package/tools/cli/installers/lib/ide/templates/combined/rovodev.md +9 -0
  607. package/tools/cli/installers/lib/ide/templates/combined/trae.md +9 -0
  608. package/tools/cli/installers/lib/ide/templates/combined/windsurf-workflow.md +10 -0
  609. package/tools/cli/installers/lib/ide/templates/split/.gitkeep +0 -0
  610. package/tools/cli/installers/lib/ide/templates/workflow-command-template.md +13 -0
  611. package/tools/cli/installers/lib/ide/templates/workflow-commander.md +5 -0
  612. package/tools/cli/installers/lib/message-loader.js +83 -0
  613. package/tools/cli/installers/lib/modules/external-manager.js +136 -0
  614. package/tools/cli/installers/lib/modules/manager.js +1498 -0
  615. package/tools/cli/lib/activation-builder.js +165 -0
  616. package/tools/cli/lib/agent/compiler.js +525 -0
  617. package/tools/cli/lib/agent/installer.js +680 -0
  618. package/tools/cli/lib/agent/template-engine.js +152 -0
  619. package/tools/cli/lib/agent-analyzer.js +109 -0
  620. package/tools/cli/lib/agent-party-generator.js +194 -0
  621. package/tools/cli/lib/cli-utils.js +182 -0
  622. package/tools/cli/lib/config.js +213 -0
  623. package/tools/cli/lib/file-ops.js +204 -0
  624. package/tools/cli/lib/platform-codes.js +116 -0
  625. package/tools/cli/lib/project-root.js +77 -0
  626. package/tools/cli/lib/prompts.js +809 -0
  627. package/tools/cli/lib/ui.js +1936 -0
  628. package/tools/cli/lib/xml-handler.js +177 -0
  629. package/tools/cli/lib/xml-to-markdown.js +82 -0
  630. package/tools/cli/lib/yaml-format.js +245 -0
  631. package/tools/cli/lib/yaml-xml-builder.js +587 -0
  632. package/tools/docs/_prompt-external-modules-page.md +59 -0
  633. package/tools/docs/fix-refs.md +91 -0
  634. package/tools/fix-doc-links.js +285 -0
  635. package/tools/format-workflow-md.js +263 -0
  636. package/tools/lib/xml-utils.js +13 -0
  637. package/tools/migrate-custom-module-paths.js +124 -0
  638. package/tools/platform-codes.yaml +157 -0
  639. package/tools/schema/agent.js +491 -0
  640. package/tools/validate-agent-schema.js +110 -0
  641. package/tools/validate-doc-links.js +407 -0
  642. package/tools/validate-file-refs.js +554 -0
  643. package/tools/validate-svg-changes.sh +356 -0
  644. package/website/README.md +75 -0
  645. package/website/astro.config.mjs +136 -0
  646. package/website/public/favicon.ico +0 -0
  647. package/website/public/img/bmad-dark.png +0 -0
  648. package/website/public/img/bmad-light.png +0 -0
  649. package/website/public/workflow-map-diagram.html +361 -0
  650. package/website/src/components/Banner.astro +62 -0
  651. package/website/src/components/Header.astro +96 -0
  652. package/website/src/components/MobileMenuFooter.astro +33 -0
  653. package/website/src/content/config.ts +6 -0
  654. package/website/src/lib/site-url.mjs +25 -0
  655. package/website/src/pages/404.astro +11 -0
  656. package/website/src/pages/robots.txt.ts +48 -0
  657. package/website/src/rehype-base-paths.js +112 -0
  658. package/website/src/rehype-markdown-links.js +119 -0
  659. package/website/src/styles/custom.css +805 -0
  660. package/.mcp.json +0 -46
  661. package/agents/AGENTS-REGISTRY.md +0 -215
  662. package/agents/architect.md +0 -160
  663. package/agents/dev.md +0 -166
  664. package/agents/devops.md +0 -230
  665. package/agents/doc.md +0 -189
  666. package/agents/learn.md +0 -377
  667. package/agents/product.md +0 -124
  668. package/agents/security.md +0 -168
  669. package/agents/test.md +0 -209
  670. package/agents/ux.md +0 -207
  671. package/cli/mdan.js +0 -628
  672. package/cli/mdan.py +0 -316
  673. package/cli/mdan.sh +0 -724
  674. package/cli/postinstall.js +0 -4
  675. package/core/orchestrator.md +0 -238
  676. package/core/universal-envelope.md +0 -160
  677. package/install.sh +0 -91
  678. package/integrations/all-integrations.md +0 -300
  679. package/integrations/claude.md +0 -46
  680. package/integrations/cursor.md +0 -74
  681. package/integrations/mcp.md +0 -153
  682. package/integrations/windsurf.md +0 -48
  683. package/memory/MDAN-STATE.template.json +0 -44
  684. package/memory/MEMORY-SYSTEM.md +0 -197
  685. package/phases/01-discover.md +0 -136
  686. package/phases/02-design.md +0 -147
  687. package/phases/03-build.md +0 -113
  688. package/phases/04-verify.md +0 -107
  689. package/phases/05-ship.md +0 -156
  690. package/skills/find-skills/skill.md +0 -133
  691. package/templates/ARCHITECTURE.md +0 -186
  692. package/templates/CHANGELOG.md +0 -41
  693. package/templates/MDAN-KNOWLEDGE.md +0 -73
  694. package/templates/PRD.md +0 -120
  695. package/templates/SECURITY-REVIEW.md +0 -99
  696. package/templates/TEST-PLAN.md +0 -97
  697. package/templates/prompts/README.md +0 -108
  698. package/templates/prompts/dev-agent.yaml +0 -85
  699. package/templates/prompts/orchestrator.yaml +0 -97
  700. package/templates/prompts.json +0 -81
  701. package/templates/tests/evaluations/README.md +0 -80
  702. package/templates/tests/evaluations/classification_eval.md +0 -136
  703. package/templates/tests/evaluations/rag_eval.md +0 -116
  704. package/templates/tests/scenarios/README.md +0 -62
  705. package/templates/tests/scenarios/basic_authentication.test.md +0 -82
  706. package/templates/tests/scenarios/user_registration.test.md +0 -107
@@ -0,0 +1,1936 @@
1
+ const path = require('node:path');
2
+ const os = require('node:os');
3
+ const fs = require('fs-extra');
4
+ const { CLIUtils } = require('./cli-utils');
5
+ const { CustomHandler } = require('../installers/lib/custom/handler');
6
+ const { ExternalModuleManager } = require('../installers/lib/modules/external-manager');
7
+ const prompts = require('./prompts');
8
+
9
+ // Separator class for visual grouping in select/multiselect prompts
10
+ // Note: @clack/prompts doesn't support separators natively, they are filtered out
11
+ class Separator {
12
+ constructor(text = '────────') {
13
+ this.line = text;
14
+ this.name = text;
15
+ }
16
+ type = 'separator';
17
+ }
18
+
19
+ // Separator for choice lists (compatible interface)
20
+ const choiceUtils = { Separator };
21
+
22
+ /**
23
+ * UI utilities for the installer
24
+ */
25
+ class UI {
26
+ /**
27
+ * Prompt for installation configuration
28
+ * @param {Object} options - Command-line options from install command
29
+ * @returns {Object} Installation configuration
30
+ */
31
+ async promptInstall(options = {}) {
32
+ await CLIUtils.displayLogo();
33
+
34
+ // Display version-specific start message from install-messages.yaml
35
+ const { MessageLoader } = require('../installers/lib/message-loader');
36
+ const messageLoader = new MessageLoader();
37
+ await messageLoader.displayStartMessage();
38
+
39
+ // Get directory from options or prompt
40
+ let confirmedDirectory;
41
+ if (options.directory) {
42
+ // Use provided directory from command-line
43
+ const expandedDir = this.expandUserPath(options.directory);
44
+ const validation = this.validateDirectorySync(expandedDir);
45
+ if (validation) {
46
+ throw new Error(`Invalid directory: ${validation}`);
47
+ }
48
+ confirmedDirectory = expandedDir;
49
+ await prompts.log.info(`Using directory from command-line: ${confirmedDirectory}`);
50
+ } else {
51
+ confirmedDirectory = await this.getConfirmedDirectory();
52
+ }
53
+
54
+ // Preflight: Check for legacy BMAD v4 footprints immediately after getting directory
55
+ const { Detector } = require('../installers/lib/core/detector');
56
+ const { Installer } = require('../installers/lib/core/installer');
57
+ const detector = new Detector();
58
+ const installer = new Installer();
59
+ const legacyV4 = await detector.detectLegacyV4(confirmedDirectory);
60
+ if (legacyV4.hasLegacyV4) {
61
+ await installer.handleLegacyV4Migration(confirmedDirectory, legacyV4);
62
+ }
63
+
64
+ // Check for legacy folders and prompt for rename before showing any menus
65
+ let hasLegacyCfg = false;
66
+ let hasLegacyBmadFolder = false;
67
+ let bmadDir = null;
68
+ let legacyBmadPath = null;
69
+
70
+ // First check for legacy .bmad folder (instead of _bmad)
71
+ // Only check if directory exists
72
+ if (await fs.pathExists(confirmedDirectory)) {
73
+ const entries = await fs.readdir(confirmedDirectory, { withFileTypes: true });
74
+ for (const entry of entries) {
75
+ if (entry.isDirectory() && (entry.name === '.bmad' || entry.name === 'bmad')) {
76
+ hasLegacyBmadFolder = true;
77
+ legacyBmadPath = path.join(confirmedDirectory, entry.name);
78
+ bmadDir = legacyBmadPath;
79
+
80
+ // Check if it has _cfg folder
81
+ const cfgPath = path.join(legacyBmadPath, '_cfg');
82
+ if (await fs.pathExists(cfgPath)) {
83
+ hasLegacyCfg = true;
84
+ }
85
+ break;
86
+ }
87
+ }
88
+ }
89
+
90
+ // If no .bmad or bmad found, check for current installations _bmad
91
+ if (!hasLegacyBmadFolder) {
92
+ const bmadResult = await installer.findBmadDir(confirmedDirectory);
93
+ bmadDir = bmadResult.bmadDir;
94
+ hasLegacyCfg = bmadResult.hasLegacyCfg;
95
+ }
96
+
97
+ // Handle legacy .bmad or _cfg folder - these are very old (v4 or alpha)
98
+ // Show version warning instead of offering conversion
99
+ if (hasLegacyBmadFolder || hasLegacyCfg) {
100
+ await prompts.log.warn('LEGACY INSTALLATION DETECTED');
101
+ await prompts.note(
102
+ 'Found a ".bmad"/"bmad" folder, or a legacy "_cfg" folder under the bmad folder -\n' +
103
+ 'this is from an old BMAD version that is out of date for automatic upgrade,\n' +
104
+ 'manual intervention required.\n\n' +
105
+ 'You have a legacy version installed (v4 or alpha).\n' +
106
+ 'Legacy installations may have compatibility issues.\n\n' +
107
+ 'For the best experience, we strongly recommend:\n' +
108
+ ' 1. Delete your current BMAD installation folder (.bmad or bmad)\n' +
109
+ ' 2. Run a fresh installation\n\n' +
110
+ 'If you do not want to start fresh, you can attempt to proceed beyond this\n' +
111
+ 'point IF you have ensured the bmad folder is named _bmad, and under it there\n' +
112
+ 'is a _config folder. If you have a folder under your bmad folder named _cfg,\n' +
113
+ 'you would need to rename it _config, and then restart the installer.\n\n' +
114
+ 'Benefits of a fresh install:\n' +
115
+ ' \u2022 Cleaner configuration without legacy artifacts\n' +
116
+ ' \u2022 All new features properly configured\n' +
117
+ ' \u2022 Fewer potential conflicts\n\n' +
118
+ 'If you have already produced output from an earlier alpha version, you can\n' +
119
+ 'still retain those artifacts. After installation, ensure you configured during\n' +
120
+ 'install the proper file locations for artifacts depending on the module you\n' +
121
+ 'are using, or move the files to the proper locations.',
122
+ 'Legacy Installation Detected',
123
+ );
124
+
125
+ const proceed = await prompts.select({
126
+ message: 'How would you like to proceed?',
127
+ choices: [
128
+ {
129
+ name: 'Cancel and do a fresh install (recommended)',
130
+ value: 'cancel',
131
+ },
132
+ {
133
+ name: 'Proceed anyway (will attempt update, potentially may fail or have unstable behavior)',
134
+ value: 'proceed',
135
+ },
136
+ ],
137
+ default: 'cancel',
138
+ });
139
+
140
+ if (proceed === 'cancel') {
141
+ await prompts.note('1. Delete the existing bmad folder in your project\n' + "2. Run 'bmad install' again", 'To do a fresh install');
142
+ process.exit(0);
143
+ return;
144
+ }
145
+
146
+ const s = await prompts.spinner();
147
+ s.start('Updating folder structure...');
148
+ try {
149
+ // Handle .bmad folder
150
+ if (hasLegacyBmadFolder) {
151
+ const newBmadPath = path.join(confirmedDirectory, '_bmad');
152
+ await fs.move(legacyBmadPath, newBmadPath);
153
+ bmadDir = newBmadPath;
154
+ s.stop(`Renamed "${path.basename(legacyBmadPath)}" to "_bmad"`);
155
+ }
156
+
157
+ // Handle _cfg folder (either from .bmad or standalone)
158
+ const cfgPath = path.join(bmadDir, '_cfg');
159
+ if (await fs.pathExists(cfgPath)) {
160
+ s.start('Renaming configuration folder...');
161
+ const newCfgPath = path.join(bmadDir, '_config');
162
+ await fs.move(cfgPath, newCfgPath);
163
+ s.stop('Renamed "_cfg" to "_config"');
164
+ }
165
+ } catch (error) {
166
+ s.stop('Failed to update folder structure');
167
+ await prompts.log.error(`Error: ${error.message}`);
168
+ process.exit(1);
169
+ }
170
+ }
171
+
172
+ // Check if there's an existing BMAD installation (after any folder renames)
173
+ const hasExistingInstall = await fs.pathExists(bmadDir);
174
+
175
+ let customContentConfig = { hasCustomContent: false };
176
+ if (!hasExistingInstall) {
177
+ customContentConfig._shouldAsk = true;
178
+ }
179
+
180
+ // Track action type (only set if there's an existing installation)
181
+ let actionType;
182
+
183
+ // Only show action menu if there's an existing installation
184
+ if (hasExistingInstall) {
185
+ // Get version information
186
+ const { existingInstall, bmadDir } = await this.getExistingInstallation(confirmedDirectory);
187
+ const packageJsonPath = path.join(__dirname, '../../../package.json');
188
+ const currentVersion = require(packageJsonPath).version;
189
+ const installedVersion = existingInstall.version || 'unknown';
190
+
191
+ // Check if version is pre beta
192
+ const shouldProceed = await this.showLegacyVersionWarning(installedVersion, currentVersion, path.basename(bmadDir), options);
193
+
194
+ // If user chose to cancel, exit the installer
195
+ if (!shouldProceed) {
196
+ process.exit(0);
197
+ return;
198
+ }
199
+
200
+ // Build menu choices dynamically
201
+ const choices = [];
202
+
203
+ // Always show Quick Update first (allows refreshing installation even on same version)
204
+ if (installedVersion !== 'unknown') {
205
+ choices.push({
206
+ name: `Quick Update (v${installedVersion} → v${currentVersion})`,
207
+ value: 'quick-update',
208
+ });
209
+ }
210
+
211
+ // Add custom agent compilation option
212
+ if (installedVersion !== 'unknown') {
213
+ choices.push({
214
+ name: 'Recompile Agents (apply customizations only)',
215
+ value: 'compile-agents',
216
+ });
217
+ }
218
+
219
+ // Common actions
220
+ choices.push({ name: 'Modify BMAD Installation', value: 'update' });
221
+
222
+ // Check if action is provided via command-line
223
+ if (options.action) {
224
+ const validActions = choices.map((c) => c.value);
225
+ if (!validActions.includes(options.action)) {
226
+ throw new Error(`Invalid action: ${options.action}. Valid actions: ${validActions.join(', ')}`);
227
+ }
228
+ actionType = options.action;
229
+ await prompts.log.info(`Using action from command-line: ${actionType}`);
230
+ } else if (options.yes) {
231
+ // Default to quick-update if available, otherwise first available choice
232
+ if (choices.length === 0) {
233
+ throw new Error('No valid actions available for this installation');
234
+ }
235
+ const hasQuickUpdate = choices.some((c) => c.value === 'quick-update');
236
+ actionType = hasQuickUpdate ? 'quick-update' : choices[0].value;
237
+ await prompts.log.info(`Non-interactive mode (--yes): defaulting to ${actionType}`);
238
+ } else {
239
+ actionType = await prompts.select({
240
+ message: 'How would you like to proceed?',
241
+ choices: choices,
242
+ default: choices[0].value,
243
+ });
244
+ }
245
+
246
+ // Handle quick update separately
247
+ if (actionType === 'quick-update') {
248
+ // Pass --custom-content through so installer can re-cache if cache is missing
249
+ let customContentForQuickUpdate = { hasCustomContent: false };
250
+ if (options.customContent) {
251
+ const paths = options.customContent
252
+ .split(',')
253
+ .map((p) => p.trim())
254
+ .filter(Boolean);
255
+ if (paths.length > 0) {
256
+ const customPaths = [];
257
+ const selectedModuleIds = [];
258
+ const sources = [];
259
+ for (const customPath of paths) {
260
+ const expandedPath = this.expandUserPath(customPath);
261
+ const validation = this.validateCustomContentPathSync(expandedPath);
262
+ if (validation) continue;
263
+ let moduleMeta;
264
+ try {
265
+ const moduleYamlPath = path.join(expandedPath, 'module.yaml');
266
+ moduleMeta = require('yaml').parse(await fs.readFile(moduleYamlPath, 'utf-8'));
267
+ } catch {
268
+ continue;
269
+ }
270
+ if (!moduleMeta?.code) continue;
271
+ customPaths.push(expandedPath);
272
+ selectedModuleIds.push(moduleMeta.code);
273
+ sources.push({ path: expandedPath, id: moduleMeta.code, name: moduleMeta.name || moduleMeta.code });
274
+ }
275
+ if (customPaths.length > 0) {
276
+ customContentForQuickUpdate = {
277
+ hasCustomContent: true,
278
+ selected: true,
279
+ sources,
280
+ selectedFiles: customPaths.map((p) => path.join(p, 'module.yaml')),
281
+ selectedModuleIds,
282
+ };
283
+ }
284
+ }
285
+ }
286
+ return {
287
+ actionType: 'quick-update',
288
+ directory: confirmedDirectory,
289
+ customContent: customContentForQuickUpdate,
290
+ skipPrompts: options.yes || false,
291
+ };
292
+ }
293
+
294
+ // Handle compile agents separately
295
+ if (actionType === 'compile-agents') {
296
+ // Only recompile agents with customizations, don't update any files
297
+ return {
298
+ actionType: 'compile-agents',
299
+ directory: confirmedDirectory,
300
+ customContent: { hasCustomContent: false },
301
+ skipPrompts: options.yes || false,
302
+ };
303
+ }
304
+
305
+ // If actionType === 'update', handle it with the new flow
306
+ // Return early with modify configuration
307
+ if (actionType === 'update') {
308
+ // Get existing installation info
309
+ const { installedModuleIds } = await this.getExistingInstallation(confirmedDirectory);
310
+
311
+ await prompts.log.message(`Found existing modules: ${[...installedModuleIds].join(', ')}`);
312
+
313
+ // Unified module selection - all modules in one grouped multiselect
314
+ let selectedModules;
315
+ if (options.modules) {
316
+ // Use modules from command-line
317
+ selectedModules = options.modules
318
+ .split(',')
319
+ .map((m) => m.trim())
320
+ .filter(Boolean);
321
+ await prompts.log.info(`Using modules from command-line: ${selectedModules.join(', ')}`);
322
+ } else if (options.yes) {
323
+ selectedModules = await this.getDefaultModules(installedModuleIds);
324
+ await prompts.log.info(
325
+ `Non-interactive mode (--yes): using default modules (installed + defaults): ${selectedModules.join(', ')}`,
326
+ );
327
+ } else {
328
+ selectedModules = await this.selectAllModules(installedModuleIds);
329
+ }
330
+
331
+ // After module selection, ask about custom modules
332
+ let customModuleResult = { selectedCustomModules: [], customContentConfig: { hasCustomContent: false } };
333
+
334
+ if (options.customContent) {
335
+ // Use custom content from command-line
336
+ const paths = options.customContent
337
+ .split(',')
338
+ .map((p) => p.trim())
339
+ .filter(Boolean);
340
+ await prompts.log.info(`Using custom content from command-line: ${paths.join(', ')}`);
341
+
342
+ // Build custom content config similar to promptCustomContentSource
343
+ const customPaths = [];
344
+ const selectedModuleIds = [];
345
+ const sources = [];
346
+
347
+ for (const customPath of paths) {
348
+ const expandedPath = this.expandUserPath(customPath);
349
+ const validation = this.validateCustomContentPathSync(expandedPath);
350
+ if (validation) {
351
+ await prompts.log.warn(`Skipping invalid custom content path: ${customPath} - ${validation}`);
352
+ continue;
353
+ }
354
+
355
+ // Read module metadata
356
+ let moduleMeta;
357
+ try {
358
+ const moduleYamlPath = path.join(expandedPath, 'module.yaml');
359
+ const moduleYaml = await fs.readFile(moduleYamlPath, 'utf-8');
360
+ const yaml = require('yaml');
361
+ moduleMeta = yaml.parse(moduleYaml);
362
+ } catch (error) {
363
+ await prompts.log.warn(`Skipping custom content path: ${customPath} - failed to read module.yaml: ${error.message}`);
364
+ continue;
365
+ }
366
+
367
+ if (!moduleMeta) {
368
+ await prompts.log.warn(`Skipping custom content path: ${customPath} - module.yaml is empty`);
369
+ continue;
370
+ }
371
+
372
+ if (!moduleMeta.code) {
373
+ await prompts.log.warn(`Skipping custom content path: ${customPath} - module.yaml missing 'code' field`);
374
+ continue;
375
+ }
376
+
377
+ customPaths.push(expandedPath);
378
+ selectedModuleIds.push(moduleMeta.code);
379
+ sources.push({
380
+ path: expandedPath,
381
+ id: moduleMeta.code,
382
+ name: moduleMeta.name || moduleMeta.code,
383
+ });
384
+ }
385
+
386
+ if (customPaths.length > 0) {
387
+ customModuleResult = {
388
+ selectedCustomModules: selectedModuleIds,
389
+ customContentConfig: {
390
+ hasCustomContent: true,
391
+ selected: true,
392
+ sources,
393
+ selectedFiles: customPaths.map((p) => path.join(p, 'module.yaml')),
394
+ selectedModuleIds: selectedModuleIds,
395
+ },
396
+ };
397
+ }
398
+ } else if (options.yes) {
399
+ // Non-interactive mode: preserve existing custom modules (matches default: false)
400
+ const cacheDir = path.join(bmadDir, '_config', 'custom');
401
+ if (await fs.pathExists(cacheDir)) {
402
+ const entries = await fs.readdir(cacheDir, { withFileTypes: true });
403
+ for (const entry of entries) {
404
+ if (entry.isDirectory()) {
405
+ customModuleResult.selectedCustomModules.push(entry.name);
406
+ }
407
+ }
408
+ await prompts.log.info(
409
+ `Non-interactive mode (--yes): preserving ${customModuleResult.selectedCustomModules.length} existing custom module(s)`,
410
+ );
411
+ } else {
412
+ await prompts.log.info('Non-interactive mode (--yes): no existing custom modules found');
413
+ }
414
+ } else {
415
+ const changeCustomModules = await prompts.confirm({
416
+ message: 'Modify custom modules, agents, or workflows?',
417
+ default: false,
418
+ });
419
+
420
+ if (changeCustomModules) {
421
+ customModuleResult = await this.handleCustomModulesInModifyFlow(confirmedDirectory, selectedModules);
422
+ } else {
423
+ // Preserve existing custom modules if user doesn't want to modify them
424
+ const { Installer } = require('../installers/lib/core/installer');
425
+ const installer = new Installer();
426
+ const { bmadDir } = await installer.findBmadDir(confirmedDirectory);
427
+
428
+ const cacheDir = path.join(bmadDir, '_config', 'custom');
429
+ if (await fs.pathExists(cacheDir)) {
430
+ const entries = await fs.readdir(cacheDir, { withFileTypes: true });
431
+ for (const entry of entries) {
432
+ if (entry.isDirectory()) {
433
+ customModuleResult.selectedCustomModules.push(entry.name);
434
+ }
435
+ }
436
+ }
437
+ }
438
+ }
439
+
440
+ // Merge any selected custom modules
441
+ if (customModuleResult.selectedCustomModules.length > 0) {
442
+ selectedModules.push(...customModuleResult.selectedCustomModules);
443
+ }
444
+
445
+ // Filter out core - it's always installed via installCore flag
446
+ selectedModules = selectedModules.filter((m) => m !== 'core');
447
+
448
+ // Get tool selection
449
+ const toolSelection = await this.promptToolSelection(confirmedDirectory, options);
450
+
451
+ const coreConfig = await this.collectCoreConfig(confirmedDirectory, options);
452
+
453
+ return {
454
+ actionType: 'update',
455
+ directory: confirmedDirectory,
456
+ installCore: true,
457
+ modules: selectedModules,
458
+ ides: toolSelection.ides,
459
+ skipIde: toolSelection.skipIde,
460
+ coreConfig: coreConfig,
461
+ customContent: customModuleResult.customContentConfig,
462
+ skipPrompts: options.yes || false,
463
+ };
464
+ }
465
+ }
466
+
467
+ // This section is only for new installations (update returns early above)
468
+ const { installedModuleIds } = await this.getExistingInstallation(confirmedDirectory);
469
+
470
+ // Unified module selection - all modules in one grouped multiselect
471
+ let selectedModules;
472
+ if (options.modules) {
473
+ // Use modules from command-line
474
+ selectedModules = options.modules
475
+ .split(',')
476
+ .map((m) => m.trim())
477
+ .filter(Boolean);
478
+ await prompts.log.info(`Using modules from command-line: ${selectedModules.join(', ')}`);
479
+ } else if (options.yes) {
480
+ // Use default modules when --yes flag is set
481
+ selectedModules = await this.getDefaultModules(installedModuleIds);
482
+ await prompts.log.info(`Using default modules (--yes flag): ${selectedModules.join(', ')}`);
483
+ } else {
484
+ selectedModules = await this.selectAllModules(installedModuleIds);
485
+ }
486
+
487
+ // Ask about custom content (local modules/agents/workflows)
488
+ if (options.customContent) {
489
+ // Use custom content from command-line
490
+ const paths = options.customContent
491
+ .split(',')
492
+ .map((p) => p.trim())
493
+ .filter(Boolean);
494
+ await prompts.log.info(`Using custom content from command-line: ${paths.join(', ')}`);
495
+
496
+ // Build custom content config similar to promptCustomContentSource
497
+ const customPaths = [];
498
+ const selectedModuleIds = [];
499
+ const sources = [];
500
+
501
+ for (const customPath of paths) {
502
+ const expandedPath = this.expandUserPath(customPath);
503
+ const validation = this.validateCustomContentPathSync(expandedPath);
504
+ if (validation) {
505
+ await prompts.log.warn(`Skipping invalid custom content path: ${customPath} - ${validation}`);
506
+ continue;
507
+ }
508
+
509
+ // Read module metadata
510
+ let moduleMeta;
511
+ try {
512
+ const moduleYamlPath = path.join(expandedPath, 'module.yaml');
513
+ const moduleYaml = await fs.readFile(moduleYamlPath, 'utf-8');
514
+ const yaml = require('yaml');
515
+ moduleMeta = yaml.parse(moduleYaml);
516
+ } catch (error) {
517
+ await prompts.log.warn(`Skipping custom content path: ${customPath} - failed to read module.yaml: ${error.message}`);
518
+ continue;
519
+ }
520
+
521
+ if (!moduleMeta) {
522
+ await prompts.log.warn(`Skipping custom content path: ${customPath} - module.yaml is empty`);
523
+ continue;
524
+ }
525
+
526
+ if (!moduleMeta.code) {
527
+ await prompts.log.warn(`Skipping custom content path: ${customPath} - module.yaml missing 'code' field`);
528
+ continue;
529
+ }
530
+
531
+ customPaths.push(expandedPath);
532
+ selectedModuleIds.push(moduleMeta.code);
533
+ sources.push({
534
+ path: expandedPath,
535
+ id: moduleMeta.code,
536
+ name: moduleMeta.name || moduleMeta.code,
537
+ });
538
+ }
539
+
540
+ if (customPaths.length > 0) {
541
+ customContentConfig = {
542
+ hasCustomContent: true,
543
+ selected: true,
544
+ sources,
545
+ selectedFiles: customPaths.map((p) => path.join(p, 'module.yaml')),
546
+ selectedModuleIds: selectedModuleIds,
547
+ };
548
+ }
549
+ } else if (!options.yes) {
550
+ const wantsCustomContent = await prompts.confirm({
551
+ message: 'Add custom modules, agents, or workflows from your computer?',
552
+ default: false,
553
+ });
554
+
555
+ if (wantsCustomContent) {
556
+ customContentConfig = await this.promptCustomContentSource();
557
+ }
558
+ }
559
+
560
+ // Add custom content modules if any were selected
561
+ if (customContentConfig && customContentConfig.selectedModuleIds) {
562
+ selectedModules.push(...customContentConfig.selectedModuleIds);
563
+ }
564
+
565
+ selectedModules = selectedModules.filter((m) => m !== 'core');
566
+ let toolSelection = await this.promptToolSelection(confirmedDirectory, options);
567
+ const coreConfig = await this.collectCoreConfig(confirmedDirectory, options);
568
+
569
+ return {
570
+ actionType: 'install',
571
+ directory: confirmedDirectory,
572
+ installCore: true,
573
+ modules: selectedModules,
574
+ ides: toolSelection.ides,
575
+ skipIde: toolSelection.skipIde,
576
+ coreConfig: coreConfig,
577
+ customContent: customContentConfig,
578
+ skipPrompts: options.yes || false,
579
+ };
580
+ }
581
+
582
+ /**
583
+ * Prompt for tool/IDE selection (called after module configuration)
584
+ * Uses a split prompt approach:
585
+ * 1. Recommended tools - standard multiselect for preferred tools
586
+ * 2. Additional tools - autocompleteMultiselect with search capability
587
+ * @param {string} projectDir - Project directory to check for existing IDEs
588
+ * @param {Object} options - Command-line options
589
+ * @returns {Object} Tool configuration
590
+ */
591
+ async promptToolSelection(projectDir, options = {}) {
592
+ // Check for existing configured IDEs - use findBmadDir to detect custom folder names
593
+ const { Detector } = require('../installers/lib/core/detector');
594
+ const { Installer } = require('../installers/lib/core/installer');
595
+ const detector = new Detector();
596
+ const installer = new Installer();
597
+ const bmadResult = await installer.findBmadDir(projectDir || process.cwd());
598
+ const bmadDir = bmadResult.bmadDir;
599
+ const existingInstall = await detector.detect(bmadDir);
600
+ const configuredIdes = existingInstall.ides || [];
601
+
602
+ // Get IDE manager to fetch available IDEs dynamically
603
+ const { IdeManager } = require('../installers/lib/ide/manager');
604
+ const ideManager = new IdeManager();
605
+ await ideManager.ensureInitialized(); // IMPORTANT: Must initialize before getting IDEs
606
+
607
+ const preferredIdes = ideManager.getPreferredIdes();
608
+ const otherIdes = ideManager.getOtherIdes();
609
+
610
+ // Determine which configured IDEs are in "preferred" vs "other" categories
611
+ const configuredPreferred = configuredIdes.filter((id) => preferredIdes.some((ide) => ide.value === id));
612
+ const configuredOther = configuredIdes.filter((id) => otherIdes.some((ide) => ide.value === id));
613
+
614
+ // Warn about previously configured tools that are no longer available
615
+ const allKnownValues = new Set([...preferredIdes, ...otherIdes].map((ide) => ide.value));
616
+ const unknownTools = configuredIdes.filter((id) => id && typeof id === 'string' && !allKnownValues.has(id));
617
+ if (unknownTools.length > 0) {
618
+ await prompts.log.warn(`Previously configured tools are no longer available: ${unknownTools.join(', ')}`);
619
+ }
620
+
621
+ // ─────────────────────────────────────────────────────────────────────────────
622
+ // UPGRADE PATH: If tools already configured, show all tools with configured at top
623
+ // ─────────────────────────────────────────────────────────────────────────────
624
+ if (configuredIdes.length > 0) {
625
+ const allTools = [...preferredIdes, ...otherIdes];
626
+
627
+ // Non-interactive: handle --tools and --yes flags before interactive prompt
628
+ if (options.tools) {
629
+ if (options.tools.toLowerCase() === 'none') {
630
+ await prompts.log.info('Skipping tool configuration (--tools none)');
631
+ return { ides: [], skipIde: true };
632
+ }
633
+ const selectedIdes = options.tools
634
+ .split(',')
635
+ .map((t) => t.trim())
636
+ .filter(Boolean);
637
+ await prompts.log.info(`Using tools from command-line: ${selectedIdes.join(', ')}`);
638
+ await this.displaySelectedTools(selectedIdes, preferredIdes, allTools);
639
+ return { ides: selectedIdes, skipIde: false };
640
+ }
641
+
642
+ if (options.yes) {
643
+ await prompts.log.info(`Non-interactive mode (--yes): keeping configured tools: ${configuredIdes.join(', ')}`);
644
+ await this.displaySelectedTools(configuredIdes, preferredIdes, allTools);
645
+ return { ides: configuredIdes, skipIde: false };
646
+ }
647
+
648
+ // Sort: configured tools first, then preferred, then others
649
+ const sortedTools = [
650
+ ...allTools.filter((ide) => configuredIdes.includes(ide.value)),
651
+ ...allTools.filter((ide) => !configuredIdes.includes(ide.value)),
652
+ ];
653
+
654
+ const upgradeOptions = sortedTools.map((ide) => {
655
+ const isConfigured = configuredIdes.includes(ide.value);
656
+ const isPreferred = preferredIdes.some((p) => p.value === ide.value);
657
+ let label = ide.name;
658
+ if (isPreferred) label += ' ⭐';
659
+ if (isConfigured) label += ' ✅';
660
+ return { label, value: ide.value };
661
+ });
662
+
663
+ // Sort initialValues to match display order
664
+ const sortedInitialValues = sortedTools.filter((ide) => configuredIdes.includes(ide.value)).map((ide) => ide.value);
665
+
666
+ const upgradeSelected = await prompts.autocompleteMultiselect({
667
+ message: 'Integrate with',
668
+ options: upgradeOptions,
669
+ initialValues: sortedInitialValues,
670
+ required: false,
671
+ maxItems: 8,
672
+ });
673
+
674
+ const selectedIdes = upgradeSelected || [];
675
+
676
+ if (selectedIdes.length === 0) {
677
+ const confirmNoTools = await prompts.confirm({
678
+ message: 'No tools selected. Continue without installing any tools?',
679
+ default: false,
680
+ });
681
+
682
+ if (!confirmNoTools) {
683
+ return this.promptToolSelection(projectDir, options);
684
+ }
685
+
686
+ return { ides: [], skipIde: true };
687
+ }
688
+
689
+ // Display selected tools
690
+ await this.displaySelectedTools(selectedIdes, preferredIdes, allTools);
691
+
692
+ return { ides: selectedIdes, skipIde: false };
693
+ }
694
+
695
+ // ─────────────────────────────────────────────────────────────────────────────
696
+ // NEW INSTALL: Show all tools with search
697
+ // ─────────────────────────────────────────────────────────────────────────────
698
+ const allTools = [...preferredIdes, ...otherIdes];
699
+
700
+ const allToolOptions = allTools.map((ide) => {
701
+ const isPreferred = preferredIdes.some((p) => p.value === ide.value);
702
+ let label = ide.name;
703
+ if (isPreferred) label += ' ⭐';
704
+ return {
705
+ label,
706
+ value: ide.value,
707
+ };
708
+ });
709
+
710
+ let selectedIdes = [];
711
+
712
+ // Check if tools are provided via command-line
713
+ if (options.tools) {
714
+ // Check for explicit "none" value to skip tool installation
715
+ if (options.tools.toLowerCase() === 'none') {
716
+ await prompts.log.info('Skipping tool configuration (--tools none)');
717
+ return { ides: [], skipIde: true };
718
+ } else {
719
+ selectedIdes = options.tools
720
+ .split(',')
721
+ .map((t) => t.trim())
722
+ .filter(Boolean);
723
+ await prompts.log.info(`Using tools from command-line: ${selectedIdes.join(', ')}`);
724
+ await this.displaySelectedTools(selectedIdes, preferredIdes, allTools);
725
+ return { ides: selectedIdes, skipIde: false };
726
+ }
727
+ } else if (options.yes) {
728
+ // If --yes flag is set, skip tool prompt and use previously configured tools or empty
729
+ if (configuredIdes.length > 0) {
730
+ await prompts.log.info(`Using previously configured tools (--yes flag): ${configuredIdes.join(', ')}`);
731
+ await this.displaySelectedTools(configuredIdes, preferredIdes, allTools);
732
+ return { ides: configuredIdes, skipIde: false };
733
+ } else {
734
+ await prompts.log.info('Skipping tool configuration (--yes flag, no previous tools)');
735
+ return { ides: [], skipIde: true };
736
+ }
737
+ }
738
+
739
+ // Interactive mode
740
+ const interactiveSelectedIdes = await prompts.autocompleteMultiselect({
741
+ message: 'Integrate with:',
742
+ options: allToolOptions,
743
+ initialValues: configuredIdes.length > 0 ? configuredIdes : undefined,
744
+ required: false,
745
+ maxItems: 8,
746
+ });
747
+
748
+ selectedIdes = interactiveSelectedIdes || [];
749
+
750
+ // ─────────────────────────────────────────────────────────────────────────────
751
+ // STEP 3: Confirm if no tools selected
752
+ // ─────────────────────────────────────────────────────────────────────────────
753
+ if (selectedIdes.length === 0) {
754
+ const confirmNoTools = await prompts.confirm({
755
+ message: 'No tools selected. Continue without installing any tools?',
756
+ default: false,
757
+ });
758
+
759
+ if (!confirmNoTools) {
760
+ // User wants to select tools - recurse
761
+ return this.promptToolSelection(projectDir, options);
762
+ }
763
+
764
+ return {
765
+ ides: [],
766
+ skipIde: true,
767
+ };
768
+ }
769
+
770
+ // Display selected tools
771
+ await this.displaySelectedTools(selectedIdes, preferredIdes, allTools);
772
+
773
+ return {
774
+ ides: selectedIdes,
775
+ skipIde: selectedIdes.length === 0,
776
+ };
777
+ }
778
+
779
+ /**
780
+ * Prompt for update configuration
781
+ * @returns {Object} Update configuration
782
+ */
783
+ async promptUpdate() {
784
+ const backupFirst = await prompts.confirm({
785
+ message: 'Create backup before updating?',
786
+ default: true,
787
+ });
788
+
789
+ const preserveCustomizations = await prompts.confirm({
790
+ message: 'Preserve local customizations?',
791
+ default: true,
792
+ });
793
+
794
+ return { backupFirst, preserveCustomizations };
795
+ }
796
+
797
+ /**
798
+ * Confirm action
799
+ * @param {string} message - Confirmation message
800
+ * @param {boolean} defaultValue - Default value
801
+ * @returns {boolean} User confirmation
802
+ */
803
+ async confirm(message, defaultValue = false) {
804
+ return await prompts.confirm({
805
+ message,
806
+ default: defaultValue,
807
+ });
808
+ }
809
+
810
+ /**
811
+ * Get confirmed directory from user
812
+ * @returns {string} Confirmed directory path
813
+ */
814
+ async getConfirmedDirectory() {
815
+ let confirmedDirectory = null;
816
+ while (!confirmedDirectory) {
817
+ const directoryAnswer = await this.promptForDirectory();
818
+ await this.displayDirectoryInfo(directoryAnswer.directory);
819
+
820
+ if (await this.confirmDirectory(directoryAnswer.directory)) {
821
+ confirmedDirectory = directoryAnswer.directory;
822
+ }
823
+ }
824
+ return confirmedDirectory;
825
+ }
826
+
827
+ /**
828
+ * Get existing installation info and installed modules
829
+ * @param {string} directory - Installation directory
830
+ * @returns {Object} Object with existingInstall, installedModuleIds, and bmadDir
831
+ */
832
+ async getExistingInstallation(directory) {
833
+ const { Detector } = require('../installers/lib/core/detector');
834
+ const { Installer } = require('../installers/lib/core/installer');
835
+ const detector = new Detector();
836
+ const installer = new Installer();
837
+ const bmadDirResult = await installer.findBmadDir(directory);
838
+ const bmadDir = bmadDirResult.bmadDir;
839
+ const existingInstall = await detector.detect(bmadDir);
840
+ const installedModuleIds = new Set(existingInstall.modules.map((mod) => mod.id));
841
+
842
+ return { existingInstall, installedModuleIds, bmadDir };
843
+ }
844
+
845
+ /**
846
+ * Collect core configuration
847
+ * @param {string} directory - Installation directory
848
+ * @param {Object} options - Command-line options
849
+ * @returns {Object} Core configuration
850
+ */
851
+ async collectCoreConfig(directory, options = {}) {
852
+ const { ConfigCollector } = require('../installers/lib/core/config-collector');
853
+ const configCollector = new ConfigCollector();
854
+
855
+ // If options are provided, set them directly
856
+ if (options.userName || options.communicationLanguage || options.documentOutputLanguage || options.outputFolder) {
857
+ const coreConfig = {};
858
+ if (options.userName) {
859
+ coreConfig.user_name = options.userName;
860
+ await prompts.log.info(`Using user name from command-line: ${options.userName}`);
861
+ }
862
+ if (options.communicationLanguage) {
863
+ coreConfig.communication_language = options.communicationLanguage;
864
+ await prompts.log.info(`Using communication language from command-line: ${options.communicationLanguage}`);
865
+ }
866
+ if (options.documentOutputLanguage) {
867
+ coreConfig.document_output_language = options.documentOutputLanguage;
868
+ await prompts.log.info(`Using document output language from command-line: ${options.documentOutputLanguage}`);
869
+ }
870
+ if (options.outputFolder) {
871
+ coreConfig.output_folder = options.outputFolder;
872
+ await prompts.log.info(`Using output folder from command-line: ${options.outputFolder}`);
873
+ }
874
+
875
+ // Load existing config to merge with provided options
876
+ await configCollector.loadExistingConfig(directory);
877
+
878
+ // Merge provided options with existing config (or defaults)
879
+ const existingConfig = configCollector.collectedConfig.core || {};
880
+ configCollector.collectedConfig.core = { ...existingConfig, ...coreConfig };
881
+
882
+ // If not all options are provided, collect the missing ones interactively (unless --yes flag)
883
+ if (
884
+ !options.yes &&
885
+ (!options.userName || !options.communicationLanguage || !options.documentOutputLanguage || !options.outputFolder)
886
+ ) {
887
+ await configCollector.collectModuleConfig('core', directory, false, true);
888
+ }
889
+ } else if (options.yes) {
890
+ // Use all defaults when --yes flag is set
891
+ await configCollector.loadExistingConfig(directory);
892
+ const existingConfig = configCollector.collectedConfig.core || {};
893
+
894
+ // If no existing config, use defaults
895
+ if (Object.keys(existingConfig).length === 0) {
896
+ let safeUsername;
897
+ try {
898
+ safeUsername = os.userInfo().username;
899
+ } catch {
900
+ safeUsername = process.env.USER || process.env.USERNAME || 'User';
901
+ }
902
+ const defaultUsername = safeUsername.charAt(0).toUpperCase() + safeUsername.slice(1);
903
+ configCollector.collectedConfig.core = {
904
+ user_name: defaultUsername,
905
+ communication_language: 'English',
906
+ document_output_language: 'English',
907
+ output_folder: '_bmad-output',
908
+ };
909
+ await prompts.log.info('Using default configuration (--yes flag)');
910
+ }
911
+ } else {
912
+ // Load existing configs first if they exist
913
+ await configCollector.loadExistingConfig(directory);
914
+ // Now collect with existing values as defaults (false = don't skip loading, true = skip completion message)
915
+ await configCollector.collectModuleConfig('core', directory, false, true);
916
+ }
917
+
918
+ const coreConfig = configCollector.collectedConfig.core;
919
+ // Ensure we always have a core config object, even if empty
920
+ return coreConfig || {};
921
+ }
922
+
923
+ /**
924
+ * Get module choices for selection
925
+ * @param {Set} installedModuleIds - Currently installed module IDs
926
+ * @param {Object} customContentConfig - Custom content configuration
927
+ * @returns {Array} Module choices for prompt
928
+ */
929
+ async getModuleChoices(installedModuleIds, customContentConfig = null) {
930
+ const color = await prompts.getColor();
931
+ const moduleChoices = [];
932
+ const isNewInstallation = installedModuleIds.size === 0;
933
+
934
+ const customContentItems = [];
935
+
936
+ // Add custom content items
937
+ if (customContentConfig && customContentConfig.hasCustomContent && customContentConfig.customPath) {
938
+ // Existing installation - show from directory
939
+ const customHandler = new CustomHandler();
940
+ const customFiles = await customHandler.findCustomContent(customContentConfig.customPath);
941
+
942
+ for (const customFile of customFiles) {
943
+ const customInfo = await customHandler.getCustomInfo(customFile);
944
+ if (customInfo) {
945
+ customContentItems.push({
946
+ name: `${color.cyan('\u2713')} ${customInfo.name} ${color.dim(`(${customInfo.relativePath})`)}`,
947
+ value: `__CUSTOM_CONTENT__${customFile}`, // Unique value for each custom content
948
+ checked: true, // Default to selected since user chose to provide custom content
949
+ path: customInfo.path, // Track path to avoid duplicates
950
+ hint: customInfo.description || undefined,
951
+ });
952
+ }
953
+ }
954
+ }
955
+
956
+ // Add official modules
957
+ const { ModuleManager } = require('../installers/lib/modules/manager');
958
+ const moduleManager = new ModuleManager();
959
+ const { modules: availableModules, customModules: customModulesFromCache } = await moduleManager.listAvailable();
960
+
961
+ // First, add all items to appropriate sections
962
+ const allCustomModules = [];
963
+
964
+ // Add custom content items from directory
965
+ allCustomModules.push(...customContentItems);
966
+
967
+ // Add custom modules from cache
968
+ for (const mod of customModulesFromCache) {
969
+ // Skip if this module is already in customContentItems (by path)
970
+ const isDuplicate = allCustomModules.some((item) => item.path && mod.path && path.resolve(item.path) === path.resolve(mod.path));
971
+
972
+ if (!isDuplicate) {
973
+ allCustomModules.push({
974
+ name: `${color.cyan('\u2713')} ${mod.name} ${color.dim('(cached)')}`,
975
+ value: mod.id,
976
+ checked: isNewInstallation ? mod.defaultSelected || false : installedModuleIds.has(mod.id),
977
+ hint: mod.description || undefined,
978
+ });
979
+ }
980
+ }
981
+
982
+ // Add separators and modules in correct order
983
+ if (allCustomModules.length > 0) {
984
+ // Add separator for custom content, all custom modules, and official content separator
985
+ moduleChoices.push(
986
+ new choiceUtils.Separator('── Custom Content ──'),
987
+ ...allCustomModules,
988
+ new choiceUtils.Separator('── Official Content ──'),
989
+ );
990
+ }
991
+
992
+ // Add official modules (only non-custom ones)
993
+ for (const mod of availableModules) {
994
+ if (!mod.isCustom) {
995
+ moduleChoices.push({
996
+ name: mod.name,
997
+ value: mod.id,
998
+ checked: isNewInstallation ? mod.defaultSelected || false : installedModuleIds.has(mod.id),
999
+ hint: mod.description || undefined,
1000
+ });
1001
+ }
1002
+ }
1003
+
1004
+ return moduleChoices;
1005
+ }
1006
+
1007
+ /**
1008
+ * Select all modules (official + community) using grouped multiselect.
1009
+ * Core is shown as locked but filtered from the result since it's always installed separately.
1010
+ * @param {Set} installedModuleIds - Currently installed module IDs
1011
+ * @returns {Array} Selected module codes (excluding core)
1012
+ */
1013
+ async selectAllModules(installedModuleIds = new Set()) {
1014
+ const { ModuleManager } = require('../installers/lib/modules/manager');
1015
+ const moduleManager = new ModuleManager();
1016
+ const { modules: localModules } = await moduleManager.listAvailable();
1017
+
1018
+ // Get external modules
1019
+ const externalManager = new ExternalModuleManager();
1020
+ const externalModules = await externalManager.listAvailable();
1021
+
1022
+ // Build flat options list with group hints for autocompleteMultiselect
1023
+ const allOptions = [];
1024
+ const initialValues = [];
1025
+ const lockedValues = ['core'];
1026
+
1027
+ // Core module is always installed — show it locked at the top
1028
+ allOptions.push({ label: 'BMad Core Module', value: 'core', hint: 'Core configuration and shared resources' });
1029
+ initialValues.push('core');
1030
+
1031
+ // Helper to build module entry with proper sorting and selection
1032
+ const buildModuleEntry = (mod, value, group) => {
1033
+ const isInstalled = installedModuleIds.has(value);
1034
+ return {
1035
+ label: mod.name,
1036
+ value,
1037
+ hint: mod.description || group,
1038
+ // Pre-select only if already installed (not on fresh install)
1039
+ selected: isInstalled,
1040
+ };
1041
+ };
1042
+
1043
+ // Local modules (BMM, BMB, etc.)
1044
+ const localEntries = [];
1045
+ for (const mod of localModules) {
1046
+ if (!mod.isCustom && mod.id !== 'core') {
1047
+ const entry = buildModuleEntry(mod, mod.id, 'Local');
1048
+ localEntries.push(entry);
1049
+ if (entry.selected) {
1050
+ initialValues.push(mod.id);
1051
+ }
1052
+ }
1053
+ }
1054
+ allOptions.push(...localEntries.map(({ label, value, hint }) => ({ label, value, hint })));
1055
+
1056
+ // Group 2: BMad Official Modules (type: bmad-org)
1057
+ const officialModules = [];
1058
+ for (const mod of externalModules) {
1059
+ if (mod.type === 'bmad-org') {
1060
+ const entry = buildModuleEntry(mod, mod.code, 'Official');
1061
+ officialModules.push(entry);
1062
+ if (entry.selected) {
1063
+ initialValues.push(mod.code);
1064
+ }
1065
+ }
1066
+ }
1067
+ allOptions.push(...officialModules.map(({ label, value, hint }) => ({ label, value, hint })));
1068
+
1069
+ // Group 3: Community Modules (type: community)
1070
+ const communityModules = [];
1071
+ for (const mod of externalModules) {
1072
+ if (mod.type === 'community') {
1073
+ const entry = buildModuleEntry(mod, mod.code, 'Community');
1074
+ communityModules.push(entry);
1075
+ if (entry.selected) {
1076
+ initialValues.push(mod.code);
1077
+ }
1078
+ }
1079
+ }
1080
+ allOptions.push(...communityModules.map(({ label, value, hint }) => ({ label, value, hint })));
1081
+
1082
+ const selected = await prompts.autocompleteMultiselect({
1083
+ message: 'Select modules to install:',
1084
+ options: allOptions,
1085
+ initialValues: initialValues.length > 0 ? initialValues : undefined,
1086
+ lockedValues,
1087
+ required: true,
1088
+ maxItems: allOptions.length,
1089
+ });
1090
+
1091
+ const result = selected ? selected.filter((m) => m !== 'core') : [];
1092
+
1093
+ // Display selected modules as bulleted list
1094
+ if (result.length > 0) {
1095
+ const moduleLines = result.map((moduleId) => {
1096
+ const opt = allOptions.find((o) => o.value === moduleId);
1097
+ return ` \u2022 ${opt?.label || moduleId}`;
1098
+ });
1099
+ await prompts.log.message('Selected modules:\n' + moduleLines.join('\n'));
1100
+ }
1101
+
1102
+ return result;
1103
+ }
1104
+
1105
+ /**
1106
+ * Get default modules for non-interactive mode
1107
+ * @param {Set} installedModuleIds - Already installed module IDs
1108
+ * @returns {Array} Default module codes
1109
+ */
1110
+ async getDefaultModules(installedModuleIds = new Set()) {
1111
+ const { ModuleManager } = require('../installers/lib/modules/manager');
1112
+ const moduleManager = new ModuleManager();
1113
+ const { modules: localModules } = await moduleManager.listAvailable();
1114
+
1115
+ const defaultModules = [];
1116
+
1117
+ // Add default-selected local modules (typically BMM)
1118
+ for (const mod of localModules) {
1119
+ if (mod.defaultSelected === true || installedModuleIds.has(mod.id)) {
1120
+ defaultModules.push(mod.id);
1121
+ }
1122
+ }
1123
+
1124
+ // If no defaults found, use 'bmm' as the fallback default
1125
+ if (defaultModules.length === 0) {
1126
+ defaultModules.push('bmm');
1127
+ }
1128
+
1129
+ return defaultModules;
1130
+ }
1131
+
1132
+ /**
1133
+ * Prompt for directory selection
1134
+ * @returns {Object} Directory answer from prompt
1135
+ */
1136
+ async promptForDirectory() {
1137
+ // Use sync validation because @clack/prompts doesn't support async validate
1138
+ const directory = await prompts.text({
1139
+ message: 'Installation directory:',
1140
+ default: process.cwd(),
1141
+ placeholder: process.cwd(),
1142
+ validate: (input) => this.validateDirectorySync(input),
1143
+ });
1144
+
1145
+ // Apply filter logic
1146
+ let filteredDir = directory;
1147
+ if (!filteredDir || filteredDir.trim() === '') {
1148
+ filteredDir = process.cwd();
1149
+ } else {
1150
+ filteredDir = this.expandUserPath(filteredDir);
1151
+ }
1152
+
1153
+ return { directory: filteredDir };
1154
+ }
1155
+
1156
+ /**
1157
+ * Display directory information
1158
+ * @param {string} directory - The directory path
1159
+ */
1160
+ async displayDirectoryInfo(directory) {
1161
+ await prompts.log.info(`Resolved installation path: ${directory}`);
1162
+
1163
+ const dirExists = await fs.pathExists(directory);
1164
+ if (dirExists) {
1165
+ // Show helpful context about the existing path
1166
+ const stats = await fs.stat(directory);
1167
+ if (stats.isDirectory()) {
1168
+ const files = await fs.readdir(directory);
1169
+ if (files.length > 0) {
1170
+ // Check for any bmad installation (any folder with _config/manifest.yaml)
1171
+ const { Installer } = require('../installers/lib/core/installer');
1172
+ const installer = new Installer();
1173
+ const bmadResult = await installer.findBmadDir(directory);
1174
+ const hasBmadInstall =
1175
+ (await fs.pathExists(bmadResult.bmadDir)) && (await fs.pathExists(path.join(bmadResult.bmadDir, '_config', 'manifest.yaml')));
1176
+
1177
+ const bmadNote = hasBmadInstall ? ` including existing BMAD installation (${path.basename(bmadResult.bmadDir)})` : '';
1178
+ await prompts.log.message(`Directory exists and contains ${files.length} item(s)${bmadNote}`);
1179
+ } else {
1180
+ await prompts.log.message('Directory exists and is empty');
1181
+ }
1182
+ }
1183
+ }
1184
+ }
1185
+
1186
+ /**
1187
+ * Confirm directory selection
1188
+ * @param {string} directory - The directory path
1189
+ * @returns {boolean} Whether user confirmed
1190
+ */
1191
+ async confirmDirectory(directory) {
1192
+ const dirExists = await fs.pathExists(directory);
1193
+
1194
+ if (dirExists) {
1195
+ const proceed = await prompts.confirm({
1196
+ message: 'Install to this directory?',
1197
+ default: true,
1198
+ });
1199
+
1200
+ if (!proceed) {
1201
+ await prompts.log.warn("Let's try again with a different path.");
1202
+ }
1203
+
1204
+ return proceed;
1205
+ } else {
1206
+ // Ask for confirmation to create the directory
1207
+ const create = await prompts.confirm({
1208
+ message: `Create directory: ${directory}?`,
1209
+ default: false,
1210
+ });
1211
+
1212
+ if (!create) {
1213
+ await prompts.log.warn("Let's try again with a different path.");
1214
+ }
1215
+
1216
+ return create;
1217
+ }
1218
+ }
1219
+
1220
+ /**
1221
+ * Validate directory path for installation (sync version for clack prompts)
1222
+ * @param {string} input - User input path
1223
+ * @returns {string|undefined} Error message or undefined if valid
1224
+ */
1225
+ validateDirectorySync(input) {
1226
+ // Allow empty input to use the default
1227
+ if (!input || input.trim() === '') {
1228
+ return; // Empty means use default, undefined = valid for clack
1229
+ }
1230
+
1231
+ let expandedPath;
1232
+ try {
1233
+ expandedPath = this.expandUserPath(input.trim());
1234
+ } catch (error) {
1235
+ return error.message;
1236
+ }
1237
+
1238
+ // Check if the path exists
1239
+ const pathExists = fs.pathExistsSync(expandedPath);
1240
+
1241
+ if (!pathExists) {
1242
+ // Find the first existing parent directory
1243
+ const existingParent = this.findExistingParentSync(expandedPath);
1244
+
1245
+ if (!existingParent) {
1246
+ return 'Cannot create directory: no existing parent directory found';
1247
+ }
1248
+
1249
+ // Check if the existing parent is writable
1250
+ try {
1251
+ fs.accessSync(existingParent, fs.constants.W_OK);
1252
+ // Path doesn't exist but can be created - will prompt for confirmation later
1253
+ return;
1254
+ } catch {
1255
+ // Provide a detailed error message explaining both issues
1256
+ return `Directory '${expandedPath}' does not exist and cannot be created: parent directory '${existingParent}' is not writable`;
1257
+ }
1258
+ }
1259
+
1260
+ // If it exists, validate it's a directory and writable
1261
+ const stat = fs.statSync(expandedPath);
1262
+ if (!stat.isDirectory()) {
1263
+ return `Path exists but is not a directory: ${expandedPath}`;
1264
+ }
1265
+
1266
+ // Check write permissions
1267
+ try {
1268
+ fs.accessSync(expandedPath, fs.constants.W_OK);
1269
+ } catch {
1270
+ return `Directory is not writable: ${expandedPath}`;
1271
+ }
1272
+
1273
+ return;
1274
+ }
1275
+
1276
+ /**
1277
+ * Validate directory path for installation (async version)
1278
+ * @param {string} input - User input path
1279
+ * @returns {string|true} Error message or true if valid
1280
+ */
1281
+ async validateDirectory(input) {
1282
+ // Allow empty input to use the default
1283
+ if (!input || input.trim() === '') {
1284
+ return true; // Empty means use default
1285
+ }
1286
+
1287
+ let expandedPath;
1288
+ try {
1289
+ expandedPath = this.expandUserPath(input.trim());
1290
+ } catch (error) {
1291
+ return error.message;
1292
+ }
1293
+
1294
+ // Check if the path exists
1295
+ const pathExists = await fs.pathExists(expandedPath);
1296
+
1297
+ if (!pathExists) {
1298
+ // Find the first existing parent directory
1299
+ const existingParent = await this.findExistingParent(expandedPath);
1300
+
1301
+ if (!existingParent) {
1302
+ return 'Cannot create directory: no existing parent directory found';
1303
+ }
1304
+
1305
+ // Check if the existing parent is writable
1306
+ try {
1307
+ await fs.access(existingParent, fs.constants.W_OK);
1308
+ // Path doesn't exist but can be created - will prompt for confirmation later
1309
+ return true;
1310
+ } catch {
1311
+ // Provide a detailed error message explaining both issues
1312
+ return `Directory '${expandedPath}' does not exist and cannot be created: parent directory '${existingParent}' is not writable`;
1313
+ }
1314
+ }
1315
+
1316
+ // If it exists, validate it's a directory and writable
1317
+ const stat = await fs.stat(expandedPath);
1318
+ if (!stat.isDirectory()) {
1319
+ return `Path exists but is not a directory: ${expandedPath}`;
1320
+ }
1321
+
1322
+ // Check write permissions
1323
+ try {
1324
+ await fs.access(expandedPath, fs.constants.W_OK);
1325
+ } catch {
1326
+ return `Directory is not writable: ${expandedPath}`;
1327
+ }
1328
+
1329
+ return true;
1330
+ }
1331
+
1332
+ /**
1333
+ * Find the first existing parent directory (sync version)
1334
+ * @param {string} targetPath - The path to check
1335
+ * @returns {string|null} The first existing parent directory, or null if none found
1336
+ */
1337
+ findExistingParentSync(targetPath) {
1338
+ let currentPath = path.resolve(targetPath);
1339
+
1340
+ // Walk up the directory tree until we find an existing directory
1341
+ while (currentPath !== path.dirname(currentPath)) {
1342
+ // Stop at root
1343
+ const parent = path.dirname(currentPath);
1344
+ if (fs.pathExistsSync(parent)) {
1345
+ return parent;
1346
+ }
1347
+ currentPath = parent;
1348
+ }
1349
+
1350
+ return null; // No existing parent found (shouldn't happen in practice)
1351
+ }
1352
+
1353
+ /**
1354
+ * Find the first existing parent directory (async version)
1355
+ * @param {string} targetPath - The path to check
1356
+ * @returns {string|null} The first existing parent directory, or null if none found
1357
+ */
1358
+ async findExistingParent(targetPath) {
1359
+ let currentPath = path.resolve(targetPath);
1360
+
1361
+ // Walk up the directory tree until we find an existing directory
1362
+ while (currentPath !== path.dirname(currentPath)) {
1363
+ // Stop at root
1364
+ const parent = path.dirname(currentPath);
1365
+ if (await fs.pathExists(parent)) {
1366
+ return parent;
1367
+ }
1368
+ currentPath = parent;
1369
+ }
1370
+
1371
+ return null; // No existing parent found (shouldn't happen in practice)
1372
+ }
1373
+
1374
+ /**
1375
+ * Expands the user-provided path: handles ~ and resolves to absolute.
1376
+ * @param {string} inputPath - User input path.
1377
+ * @returns {string} Absolute expanded path.
1378
+ */
1379
+ expandUserPath(inputPath) {
1380
+ if (typeof inputPath !== 'string') {
1381
+ throw new TypeError('Path must be a string.');
1382
+ }
1383
+
1384
+ let expanded = inputPath.trim();
1385
+
1386
+ // Handle tilde expansion
1387
+ if (expanded.startsWith('~')) {
1388
+ if (expanded === '~') {
1389
+ expanded = os.homedir();
1390
+ } else if (expanded.startsWith('~' + path.sep)) {
1391
+ const pathAfterHome = expanded.slice(2); // Remove ~/ or ~\
1392
+ expanded = path.join(os.homedir(), pathAfterHome);
1393
+ } else {
1394
+ const restOfPath = expanded.slice(1);
1395
+ const separatorIndex = restOfPath.indexOf(path.sep);
1396
+ const username = separatorIndex === -1 ? restOfPath : restOfPath.slice(0, separatorIndex);
1397
+ if (username) {
1398
+ throw new Error(`Path expansion for ~${username} is not supported. Please use an absolute path or ~${path.sep}`);
1399
+ }
1400
+ }
1401
+ }
1402
+
1403
+ // Resolve to the absolute path relative to the current working directory
1404
+ return path.resolve(expanded);
1405
+ }
1406
+
1407
+ /**
1408
+ * Load existing configurations to use as defaults
1409
+ * @param {string} directory - Installation directory
1410
+ * @returns {Object} Existing configurations
1411
+ */
1412
+ async loadExistingConfigurations(directory) {
1413
+ const configs = {
1414
+ hasCustomContent: false,
1415
+ coreConfig: {},
1416
+ ideConfig: { ides: [], skipIde: false },
1417
+ };
1418
+
1419
+ try {
1420
+ // Load core config
1421
+ configs.coreConfig = await this.collectCoreConfig(directory);
1422
+
1423
+ // Load IDE configuration
1424
+ const configuredIdes = await this.getConfiguredIdes(directory);
1425
+ if (configuredIdes.length > 0) {
1426
+ configs.ideConfig.ides = configuredIdes;
1427
+ configs.ideConfig.skipIde = false;
1428
+ }
1429
+
1430
+ return configs;
1431
+ } catch {
1432
+ // If loading fails, return empty configs
1433
+ await prompts.log.warn('Could not load existing configurations');
1434
+ return configs;
1435
+ }
1436
+ }
1437
+
1438
+ /**
1439
+ * Get configured IDEs from existing installation
1440
+ * @param {string} directory - Installation directory
1441
+ * @returns {Array} List of configured IDEs
1442
+ */
1443
+ async getConfiguredIdes(directory) {
1444
+ const { Detector } = require('../installers/lib/core/detector');
1445
+ const { Installer } = require('../installers/lib/core/installer');
1446
+ const detector = new Detector();
1447
+ const installer = new Installer();
1448
+ const bmadResult = await installer.findBmadDir(directory);
1449
+ const existingInstall = await detector.detect(bmadResult.bmadDir);
1450
+ return existingInstall.ides || [];
1451
+ }
1452
+
1453
+ /**
1454
+ * Validate custom content path synchronously
1455
+ * @param {string} input - User input path
1456
+ * @returns {string|undefined} Error message or undefined if valid
1457
+ */
1458
+ validateCustomContentPathSync(input) {
1459
+ // Allow empty input to cancel
1460
+ if (!input || input.trim() === '') {
1461
+ return; // Allow empty to exit
1462
+ }
1463
+
1464
+ try {
1465
+ // Expand the path
1466
+ const expandedPath = this.expandUserPath(input.trim());
1467
+
1468
+ // Check if path exists
1469
+ if (!fs.pathExistsSync(expandedPath)) {
1470
+ return 'Path does not exist';
1471
+ }
1472
+
1473
+ // Check if it's a directory
1474
+ const stat = fs.statSync(expandedPath);
1475
+ if (!stat.isDirectory()) {
1476
+ return 'Path must be a directory';
1477
+ }
1478
+
1479
+ // Check for module.yaml in the root
1480
+ const moduleYamlPath = path.join(expandedPath, 'module.yaml');
1481
+ if (!fs.pathExistsSync(moduleYamlPath)) {
1482
+ return 'Directory must contain a module.yaml file in the root';
1483
+ }
1484
+
1485
+ // Try to parse the module.yaml to get the module ID
1486
+ try {
1487
+ const yaml = require('yaml');
1488
+ const content = fs.readFileSync(moduleYamlPath, 'utf8');
1489
+ const moduleData = yaml.parse(content);
1490
+ if (!moduleData.code) {
1491
+ return 'module.yaml must contain a "code" field for the module ID';
1492
+ }
1493
+ } catch (error) {
1494
+ return 'Invalid module.yaml file: ' + error.message;
1495
+ }
1496
+
1497
+ return; // Valid
1498
+ } catch (error) {
1499
+ return 'Error validating path: ' + error.message;
1500
+ }
1501
+ }
1502
+
1503
+ /**
1504
+ * Prompt user for custom content source location
1505
+ * @returns {Object} Custom content configuration
1506
+ */
1507
+ async promptCustomContentSource() {
1508
+ const customContentConfig = { hasCustomContent: true, sources: [] };
1509
+
1510
+ // Keep asking for more sources until user is done
1511
+ while (true) {
1512
+ // First ask if user wants to add another module or continue
1513
+ if (customContentConfig.sources.length > 0) {
1514
+ const action = await prompts.select({
1515
+ message: 'Would you like to:',
1516
+ choices: [
1517
+ { name: 'Add another custom module', value: 'add' },
1518
+ { name: 'Continue with installation', value: 'continue' },
1519
+ ],
1520
+ default: 'continue',
1521
+ });
1522
+
1523
+ if (action === 'continue') {
1524
+ break;
1525
+ }
1526
+ }
1527
+
1528
+ let sourcePath;
1529
+ let isValid = false;
1530
+
1531
+ while (!isValid) {
1532
+ // Use sync validation because @clack/prompts doesn't support async validate
1533
+ const inputPath = await prompts.text({
1534
+ message: 'Path to custom module folder (press Enter to skip):',
1535
+ validate: (input) => this.validateCustomContentPathSync(input),
1536
+ });
1537
+
1538
+ // If user pressed Enter without typing anything, exit the loop
1539
+ if (!inputPath || inputPath.trim() === '') {
1540
+ // If we have no modules yet, return false for no custom content
1541
+ if (customContentConfig.sources.length === 0) {
1542
+ return { hasCustomContent: false };
1543
+ }
1544
+ return customContentConfig;
1545
+ }
1546
+
1547
+ sourcePath = this.expandUserPath(inputPath);
1548
+ isValid = true;
1549
+ }
1550
+
1551
+ // Read module.yaml to get module info
1552
+ const yaml = require('yaml');
1553
+ const moduleYamlPath = path.join(sourcePath, 'module.yaml');
1554
+ const moduleContent = await fs.readFile(moduleYamlPath, 'utf8');
1555
+ const moduleData = yaml.parse(moduleContent);
1556
+
1557
+ // Add to sources
1558
+ customContentConfig.sources.push({
1559
+ path: sourcePath,
1560
+ id: moduleData.code,
1561
+ name: moduleData.name || moduleData.code,
1562
+ });
1563
+
1564
+ await prompts.log.success(`Confirmed local custom module: ${moduleData.name || moduleData.code}`);
1565
+ }
1566
+
1567
+ // Ask if user wants to add these to the installation
1568
+ const shouldInstall = await prompts.confirm({
1569
+ message: `Install these ${customContentConfig.sources.length} custom modules?`,
1570
+ default: true,
1571
+ });
1572
+
1573
+ if (shouldInstall) {
1574
+ customContentConfig.selected = true;
1575
+ // Store paths to module.yaml files, not directories
1576
+ customContentConfig.selectedFiles = customContentConfig.sources.map((s) => path.join(s.path, 'module.yaml'));
1577
+ // Also include module IDs for installation
1578
+ customContentConfig.selectedModuleIds = customContentConfig.sources.map((s) => s.id);
1579
+ }
1580
+
1581
+ return customContentConfig;
1582
+ }
1583
+
1584
+ /**
1585
+ * Handle custom modules in the modify flow
1586
+ * @param {string} directory - Installation directory
1587
+ * @param {Array} selectedModules - Currently selected modules
1588
+ * @returns {Object} Result with selected custom modules and custom content config
1589
+ */
1590
+ async handleCustomModulesInModifyFlow(directory, selectedModules) {
1591
+ // Get existing installation to find custom modules
1592
+ const { existingInstall } = await this.getExistingInstallation(directory);
1593
+
1594
+ // Check if there are any custom modules in cache
1595
+ const { Installer } = require('../installers/lib/core/installer');
1596
+ const installer = new Installer();
1597
+ const { bmadDir } = await installer.findBmadDir(directory);
1598
+
1599
+ const cacheDir = path.join(bmadDir, '_config', 'custom');
1600
+ const cachedCustomModules = [];
1601
+
1602
+ if (await fs.pathExists(cacheDir)) {
1603
+ const entries = await fs.readdir(cacheDir, { withFileTypes: true });
1604
+ for (const entry of entries) {
1605
+ if (entry.isDirectory()) {
1606
+ const moduleYamlPath = path.join(cacheDir, entry.name, 'module.yaml');
1607
+ if (await fs.pathExists(moduleYamlPath)) {
1608
+ const yaml = require('yaml');
1609
+ const content = await fs.readFile(moduleYamlPath, 'utf8');
1610
+ const moduleData = yaml.parse(content);
1611
+
1612
+ cachedCustomModules.push({
1613
+ id: entry.name,
1614
+ name: moduleData.name || entry.name,
1615
+ description: moduleData.description || 'Custom module from cache',
1616
+ checked: selectedModules.includes(entry.name),
1617
+ fromCache: true,
1618
+ });
1619
+ }
1620
+ }
1621
+ }
1622
+ }
1623
+
1624
+ const result = {
1625
+ selectedCustomModules: [],
1626
+ customContentConfig: { hasCustomContent: false },
1627
+ };
1628
+
1629
+ // Ask user about custom modules
1630
+ await prompts.log.info('Custom Modules');
1631
+ if (cachedCustomModules.length > 0) {
1632
+ await prompts.log.message('Found custom modules in your installation:');
1633
+ } else {
1634
+ await prompts.log.message('No custom modules currently installed.');
1635
+ }
1636
+
1637
+ // Build choices dynamically based on whether we have existing modules
1638
+ const choices = [];
1639
+ if (cachedCustomModules.length > 0) {
1640
+ choices.push(
1641
+ { name: 'Keep all existing custom modules', value: 'keep' },
1642
+ { name: 'Select which custom modules to keep', value: 'select' },
1643
+ { name: 'Add new custom modules', value: 'add' },
1644
+ { name: 'Remove all custom modules', value: 'remove' },
1645
+ );
1646
+ } else {
1647
+ choices.push({ name: 'Add new custom modules', value: 'add' }, { name: 'Cancel (no custom modules)', value: 'cancel' });
1648
+ }
1649
+
1650
+ const customAction = await prompts.select({
1651
+ message: cachedCustomModules.length > 0 ? 'Manage custom modules?' : 'Add custom modules?',
1652
+ choices: choices,
1653
+ default: cachedCustomModules.length > 0 ? 'keep' : 'add',
1654
+ });
1655
+
1656
+ switch (customAction) {
1657
+ case 'keep': {
1658
+ // Keep all existing custom modules
1659
+ result.selectedCustomModules = cachedCustomModules.map((m) => m.id);
1660
+ await prompts.log.message(`Keeping ${result.selectedCustomModules.length} custom module(s)`);
1661
+ break;
1662
+ }
1663
+
1664
+ case 'select': {
1665
+ // Let user choose which to keep
1666
+ const selectChoices = cachedCustomModules.map((m) => ({
1667
+ name: `${m.name} (${m.id})`,
1668
+ value: m.id,
1669
+ checked: m.checked,
1670
+ }));
1671
+
1672
+ // Add "None / I changed my mind" option at the end
1673
+ const choicesWithSkip = [
1674
+ ...selectChoices,
1675
+ {
1676
+ name: '⚠ None / I changed my mind - keep no custom modules',
1677
+ value: '__NONE__',
1678
+ checked: false,
1679
+ },
1680
+ ];
1681
+
1682
+ const keepModules = await prompts.multiselect({
1683
+ message: 'Select custom modules to keep (use arrow keys, space to toggle):',
1684
+ choices: choicesWithSkip,
1685
+ required: true,
1686
+ });
1687
+
1688
+ // If user selected both "__NONE__" and other modules, honor the "None" choice
1689
+ if (keepModules && keepModules.includes('__NONE__') && keepModules.length > 1) {
1690
+ await prompts.log.warn('"None / I changed my mind" was selected, so no custom modules will be kept.');
1691
+ result.selectedCustomModules = [];
1692
+ } else {
1693
+ // Filter out the special '__NONE__' value
1694
+ result.selectedCustomModules = keepModules ? keepModules.filter((m) => m !== '__NONE__') : [];
1695
+ }
1696
+ break;
1697
+ }
1698
+
1699
+ case 'add': {
1700
+ // By default, keep existing modules when adding new ones
1701
+ // User chose "Add new" not "Replace", so we assume they want to keep existing
1702
+ result.selectedCustomModules = cachedCustomModules.map((m) => m.id);
1703
+
1704
+ // Then prompt for new ones (reuse existing method)
1705
+ const newCustomContent = await this.promptCustomContentSource();
1706
+ if (newCustomContent.hasCustomContent && newCustomContent.selected) {
1707
+ result.selectedCustomModules.push(...newCustomContent.selectedModuleIds);
1708
+ result.customContentConfig = newCustomContent;
1709
+ }
1710
+ break;
1711
+ }
1712
+
1713
+ case 'remove': {
1714
+ // Remove all custom modules
1715
+ await prompts.log.warn('All custom modules will be removed from the installation');
1716
+ break;
1717
+ }
1718
+
1719
+ case 'cancel': {
1720
+ // User cancelled - no custom modules
1721
+ await prompts.log.message('No custom modules will be added');
1722
+ break;
1723
+ }
1724
+ }
1725
+
1726
+ return result;
1727
+ }
1728
+
1729
+ /**
1730
+ * Check if installed version is a legacy version that needs fresh install
1731
+ * @param {string} installedVersion - The installed version
1732
+ * @returns {boolean} True if legacy (v4 or any alpha)
1733
+ */
1734
+ isLegacyVersion(installedVersion) {
1735
+ if (!installedVersion || installedVersion === 'unknown') {
1736
+ return true; // Treat unknown as legacy for safety
1737
+ }
1738
+ // Check if version string contains -alpha or -Alpha (any v6 alpha)
1739
+ return /-alpha\./i.test(installedVersion);
1740
+ }
1741
+
1742
+ /**
1743
+ * Show warning for legacy version (v4 or alpha) and ask if user wants to proceed
1744
+ * @param {string} installedVersion - The installed version
1745
+ * @param {string} currentVersion - The current version
1746
+ * @param {string} bmadFolderName - Name of the BMAD folder
1747
+ * @returns {Promise<boolean>} True if user wants to proceed, false if they cancel
1748
+ */
1749
+ async showLegacyVersionWarning(installedVersion, currentVersion, bmadFolderName, options = {}) {
1750
+ if (!this.isLegacyVersion(installedVersion)) {
1751
+ return true; // Not legacy, proceed
1752
+ }
1753
+
1754
+ let warningContent;
1755
+ if (installedVersion === 'unknown') {
1756
+ warningContent = 'Unable to detect your installed BMAD version.\n' + 'This appears to be a legacy or unsupported installation.';
1757
+ } else {
1758
+ warningContent =
1759
+ `You are updating from ${installedVersion} to ${currentVersion}.\n` + 'You have a legacy version installed (v4 or alpha).';
1760
+ }
1761
+
1762
+ warningContent +=
1763
+ '\n\nFor the best experience, we recommend:\n' +
1764
+ ' 1. Delete your current BMAD installation folder\n' +
1765
+ ` (the "${bmadFolderName}/" folder in your project)\n` +
1766
+ ' 2. Run a fresh installation\n\n' +
1767
+ 'Benefits of a fresh install:\n' +
1768
+ ' \u2022 Cleaner configuration without legacy artifacts\n' +
1769
+ ' \u2022 All new features properly configured\n' +
1770
+ ' \u2022 Fewer potential conflicts';
1771
+
1772
+ await prompts.log.warn('VERSION WARNING');
1773
+ await prompts.note(warningContent, 'Version Warning');
1774
+
1775
+ if (options.yes) {
1776
+ await prompts.log.warn('Non-interactive mode (--yes): auto-proceeding with legacy update');
1777
+ return true;
1778
+ }
1779
+
1780
+ const proceed = await prompts.select({
1781
+ message: 'How would you like to proceed?',
1782
+ choices: [
1783
+ {
1784
+ name: 'Proceed with update anyway (may have issues)',
1785
+ value: 'proceed',
1786
+ },
1787
+ {
1788
+ name: 'Cancel (recommended - do a fresh install instead)',
1789
+ value: 'cancel',
1790
+ },
1791
+ ],
1792
+ default: 'cancel',
1793
+ });
1794
+
1795
+ if (proceed === 'cancel') {
1796
+ await prompts.note(
1797
+ `1. Delete the "${bmadFolderName}/" folder in your project\n` + "2. Run 'bmad install' again",
1798
+ 'To do a fresh install',
1799
+ );
1800
+ }
1801
+
1802
+ return proceed === 'proceed';
1803
+ }
1804
+
1805
+ /**
1806
+ * Display module versions with update availability
1807
+ * @param {Array} modules - Array of module info objects with version info
1808
+ * @param {Array} availableUpdates - Array of available updates
1809
+ */
1810
+ async displayModuleVersions(modules, availableUpdates = []) {
1811
+ // Group modules by source
1812
+ const builtIn = modules.filter((m) => m.source === 'built-in');
1813
+ const external = modules.filter((m) => m.source === 'external');
1814
+ const custom = modules.filter((m) => m.source === 'custom');
1815
+ const unknown = modules.filter((m) => m.source === 'unknown');
1816
+
1817
+ const lines = [];
1818
+ const formatGroup = (group, title) => {
1819
+ if (group.length === 0) return;
1820
+ lines.push(title);
1821
+ for (const mod of group) {
1822
+ const updateInfo = availableUpdates.find((u) => u.name === mod.name);
1823
+ const versionDisplay = mod.version || 'unknown';
1824
+ if (updateInfo) {
1825
+ lines.push(` ${mod.name.padEnd(20)} ${versionDisplay} \u2192 ${updateInfo.latestVersion} \u2191`);
1826
+ } else {
1827
+ lines.push(` ${mod.name.padEnd(20)} ${versionDisplay} \u2713`);
1828
+ }
1829
+ }
1830
+ };
1831
+
1832
+ formatGroup(builtIn, 'Built-in Modules');
1833
+ formatGroup(external, 'External Modules (Official)');
1834
+ formatGroup(custom, 'Custom Modules');
1835
+ formatGroup(unknown, 'Other Modules');
1836
+
1837
+ await prompts.note(lines.join('\n'), 'Module Versions');
1838
+ }
1839
+
1840
+ /**
1841
+ * Prompt user to select which modules to update
1842
+ * @param {Array} availableUpdates - Array of available updates
1843
+ * @returns {Array} Selected module names to update
1844
+ */
1845
+ async promptUpdateSelection(availableUpdates) {
1846
+ if (availableUpdates.length === 0) {
1847
+ return [];
1848
+ }
1849
+
1850
+ await prompts.log.info('Available Updates');
1851
+
1852
+ const choices = availableUpdates.map((update) => ({
1853
+ name: `${update.name} (v${update.installedVersion} \u2192 v${update.latestVersion})`,
1854
+ value: update.name,
1855
+ checked: true, // Default to selecting all updates
1856
+ }));
1857
+
1858
+ // Add "Update All" and "Cancel" options
1859
+ const action = await prompts.select({
1860
+ message: 'How would you like to proceed?',
1861
+ choices: [
1862
+ { name: 'Update all available modules', value: 'all' },
1863
+ { name: 'Select specific modules to update', value: 'select' },
1864
+ { name: 'Skip updates for now', value: 'skip' },
1865
+ ],
1866
+ default: 'all',
1867
+ });
1868
+
1869
+ if (action === 'all') {
1870
+ return availableUpdates.map((u) => u.name);
1871
+ }
1872
+
1873
+ if (action === 'skip') {
1874
+ return [];
1875
+ }
1876
+
1877
+ // Allow specific selection
1878
+ const selected = await prompts.multiselect({
1879
+ message: 'Select modules to update (use arrow keys, space to toggle):',
1880
+ choices: choices,
1881
+ required: true,
1882
+ });
1883
+
1884
+ return selected || [];
1885
+ }
1886
+
1887
+ /**
1888
+ * Display status of all installed modules
1889
+ * @param {Object} statusData - Status data with modules, installation info, and available updates
1890
+ */
1891
+ async displayStatus(statusData) {
1892
+ const { installation, modules, availableUpdates, bmadDir } = statusData;
1893
+
1894
+ // Installation info
1895
+ const infoLines = [
1896
+ `Version: ${installation.version || 'unknown'}`,
1897
+ `Location: ${bmadDir}`,
1898
+ `Installed: ${new Date(installation.installDate).toLocaleDateString()}`,
1899
+ `Last Updated: ${installation.lastUpdated ? new Date(installation.lastUpdated).toLocaleDateString() : 'unknown'}`,
1900
+ ];
1901
+
1902
+ await prompts.note(infoLines.join('\n'), 'BMAD Status');
1903
+
1904
+ // Module versions
1905
+ await this.displayModuleVersions(modules, availableUpdates);
1906
+
1907
+ // Update summary
1908
+ if (availableUpdates.length > 0) {
1909
+ await prompts.log.warn(`${availableUpdates.length} update(s) available`);
1910
+ await prompts.log.message('Run \'bmad install\' and select "Quick Update" to update');
1911
+ } else {
1912
+ await prompts.log.success('All modules are up to date');
1913
+ }
1914
+ }
1915
+
1916
+ /**
1917
+ * Display list of selected tools after IDE selection
1918
+ * @param {Array} selectedIdes - Array of selected IDE values
1919
+ * @param {Array} preferredIdes - Array of preferred IDE objects
1920
+ * @param {Array} allTools - Array of all tool objects
1921
+ */
1922
+ async displaySelectedTools(selectedIdes, preferredIdes, allTools) {
1923
+ if (selectedIdes.length === 0) return;
1924
+
1925
+ const preferredValues = new Set(preferredIdes.map((ide) => ide.value));
1926
+ const toolLines = selectedIdes.map((ideValue) => {
1927
+ const tool = allTools.find((t) => t.value === ideValue);
1928
+ const name = tool?.name || ideValue;
1929
+ const marker = preferredValues.has(ideValue) ? ' \u2B50' : '';
1930
+ return ` \u2022 ${name}${marker}`;
1931
+ });
1932
+ await prompts.log.message('Selected tools:\n' + toolLines.join('\n'));
1933
+ }
1934
+ }
1935
+
1936
+ module.exports = { UI };