bmad-method 6.12.4 → 7.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (389) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +107 -54
  3. package/agents.json +640 -0
  4. package/bin/bmad-method.js +4 -0
  5. package/messages.yaml +267 -0
  6. package/modules.yaml +56 -0
  7. package/package.json +32 -110
  8. package/src/agent-picks.js +77 -0
  9. package/src/agents.js +141 -0
  10. package/src/bmad-scripts.js +167 -0
  11. package/src/cli.js +266 -0
  12. package/src/commands/agent-choice.js +67 -0
  13. package/src/commands/apply.js +38 -0
  14. package/src/commands/deps.js +25 -0
  15. package/src/commands/ending.js +66 -0
  16. package/src/commands/existing-install.js +50 -0
  17. package/src/commands/install-plan.js +130 -0
  18. package/src/commands/install-steps.js +66 -0
  19. package/src/commands/install.js +86 -0
  20. package/src/commands/status.js +39 -0
  21. package/src/commands/update.js +106 -0
  22. package/src/installed.js +48 -0
  23. package/src/messages.js +84 -0
  24. package/src/modules.js +221 -0
  25. package/src/preflight.js +124 -0
  26. package/src/project-lock.js +68 -0
  27. package/src/prompts.js +626 -0
  28. package/src/report.js +199 -0
  29. package/src/run.js +128 -0
  30. package/src/self-update.js +88 -0
  31. package/src/skills-cli.js +133 -0
  32. package/src/version.js +11 -0
  33. package/.claude-plugin/marketplace.json +0 -53
  34. package/AGENTS.md +0 -24
  35. package/CLAUDE.md +0 -1
  36. package/README_CN.md +0 -98
  37. package/README_KR.md +0 -90
  38. package/README_VN.md +0 -99
  39. package/bmad-modules.yaml +0 -140
  40. package/body.md +0 -17
  41. package/greptile.json +0 -52
  42. package/pr2.md +0 -11
  43. package/removals.txt +0 -87
  44. package/src/bmm-skills/agents/bmad-agent-analyst/SKILL.md +0 -76
  45. package/src/bmm-skills/agents/bmad-agent-analyst/customize.toml +0 -103
  46. package/src/bmm-skills/agents/bmad-agent-architect/SKILL.md +0 -76
  47. package/src/bmm-skills/agents/bmad-agent-architect/customize.toml +0 -63
  48. package/src/bmm-skills/agents/bmad-agent-dev/SKILL.md +0 -76
  49. package/src/bmm-skills/agents/bmad-agent-dev/customize.toml +0 -81
  50. package/src/bmm-skills/agents/bmad-agent-pm/SKILL.md +0 -76
  51. package/src/bmm-skills/agents/bmad-agent-pm/customize.toml +0 -73
  52. package/src/bmm-skills/agents/bmad-agent-ux-designer/SKILL.md +0 -76
  53. package/src/bmm-skills/agents/bmad-agent-ux-designer/customize.toml +0 -58
  54. package/src/bmm-skills/module-help.csv +0 -19
  55. package/src/bmm-skills/module.yaml +0 -85
  56. package/src/bmm-skills/plan/bmad-architecture/SKILL.md +0 -85
  57. package/src/bmm-skills/plan/bmad-architecture/assets/spine-template.md +0 -79
  58. package/src/bmm-skills/plan/bmad-architecture/customize.toml +0 -101
  59. package/src/bmm-skills/plan/bmad-architecture/references/headless.md +0 -26
  60. package/src/bmm-skills/plan/bmad-architecture/references/reviewer-gate.md +0 -13
  61. package/src/bmm-skills/plan/bmad-architecture/scripts/lint_spine.py +0 -261
  62. package/src/bmm-skills/plan/bmad-architecture/scripts/tests/test_lint_spine.py +0 -270
  63. package/src/bmm-skills/plan/bmad-create-epics-and-stories/SKILL.md +0 -93
  64. package/src/bmm-skills/plan/bmad-create-epics-and-stories/customize.toml +0 -39
  65. package/src/bmm-skills/plan/bmad-create-epics-and-stories/steps/step-01-validate-prerequisites.md +0 -263
  66. package/src/bmm-skills/plan/bmad-create-epics-and-stories/steps/step-02-design-epics.md +0 -242
  67. package/src/bmm-skills/plan/bmad-create-epics-and-stories/steps/step-03-create-stories.md +0 -255
  68. package/src/bmm-skills/plan/bmad-create-epics-and-stories/steps/step-04-final-validation.md +0 -141
  69. package/src/bmm-skills/plan/bmad-create-epics-and-stories/templates/epics-template.md +0 -62
  70. package/src/bmm-skills/plan/bmad-generate-project-context/SKILL.md +0 -12
  71. package/src/bmm-skills/plan/bmad-prd/SKILL.md +0 -94
  72. package/src/bmm-skills/plan/bmad-prd/assets/headless-schemas.md +0 -76
  73. package/src/bmm-skills/plan/bmad-prd/assets/prd-template.md +0 -165
  74. package/src/bmm-skills/plan/bmad-prd/assets/prd-validation-checklist.md +0 -135
  75. package/src/bmm-skills/plan/bmad-prd/assets/validation-report-template.html +0 -325
  76. package/src/bmm-skills/plan/bmad-prd/customize.toml +0 -148
  77. package/src/bmm-skills/plan/bmad-prd/references/headless.md +0 -39
  78. package/src/bmm-skills/plan/bmad-prd/references/validate.md +0 -97
  79. package/src/bmm-skills/plan/bmad-prfaq/SKILL.md +0 -135
  80. package/src/bmm-skills/plan/bmad-prfaq/agents/artifact-analyzer.md +0 -60
  81. package/src/bmm-skills/plan/bmad-prfaq/agents/web-researcher.md +0 -49
  82. package/src/bmm-skills/plan/bmad-prfaq/assets/prfaq-template.md +0 -62
  83. package/src/bmm-skills/plan/bmad-prfaq/bmad-manifest.json +0 -16
  84. package/src/bmm-skills/plan/bmad-prfaq/customize.toml +0 -39
  85. package/src/bmm-skills/plan/bmad-prfaq/references/customer-faq.md +0 -55
  86. package/src/bmm-skills/plan/bmad-prfaq/references/internal-faq.md +0 -51
  87. package/src/bmm-skills/plan/bmad-prfaq/references/press-release.md +0 -60
  88. package/src/bmm-skills/plan/bmad-prfaq/references/verdict.md +0 -83
  89. package/src/bmm-skills/plan/bmad-product-brief/SKILL.md +0 -91
  90. package/src/bmm-skills/plan/bmad-product-brief/assets/brief-template.md +0 -41
  91. package/src/bmm-skills/plan/bmad-product-brief/customize.toml +0 -100
  92. package/src/bmm-skills/plan/bmad-project-context/SKILL.md +0 -121
  93. package/src/bmm-skills/plan/bmad-project-context/customize.toml +0 -24
  94. package/src/bmm-skills/plan/bmad-project-context/references/best-practices.md +0 -84
  95. package/src/bmm-skills/plan/bmad-project-context/references/template.md +0 -55
  96. package/src/bmm-skills/plan/bmad-spec/SKILL.md +0 -160
  97. package/src/bmm-skills/plan/bmad-spec/assets/headless-schemas.md +0 -33
  98. package/src/bmm-skills/plan/bmad-spec/assets/spec-template.md +0 -49
  99. package/src/bmm-skills/plan/bmad-spec/assets/stories-schema.md +0 -44
  100. package/src/bmm-skills/plan/bmad-spec/customize.toml +0 -52
  101. package/src/bmm-skills/plan/bmad-sprint-planning/SKILL.md +0 -62
  102. package/src/bmm-skills/plan/bmad-sprint-planning/customize.toml +0 -39
  103. package/src/bmm-skills/plan/bmad-sprint-planning/references/fix-sprint-status.md +0 -30
  104. package/src/bmm-skills/plan/bmad-sprint-planning/references/generate-tracking.md +0 -25
  105. package/src/bmm-skills/plan/bmad-sprint-planning/references/readiness-gate.md +0 -20
  106. package/src/bmm-skills/plan/bmad-sprint-planning/references/status-view.md +0 -14
  107. package/src/bmm-skills/plan/bmad-sprint-planning/references/validate.md +0 -10
  108. package/src/bmm-skills/plan/bmad-sprint-planning/scripts/__pycache__/sprint_plan.cpython-311.pyc +0 -0
  109. package/src/bmm-skills/plan/bmad-sprint-planning/scripts/sprint_plan.py +0 -701
  110. package/src/bmm-skills/plan/bmad-sprint-planning/scripts/tests/__pycache__/test_sprint_plan.cpython-311-pytest-9.1.1.pyc +0 -0
  111. package/src/bmm-skills/plan/bmad-sprint-planning/scripts/tests/test_sprint_plan.py +0 -524
  112. package/src/bmm-skills/plan/bmad-sprint-planning/sprint-status-template.yaml +0 -71
  113. package/src/bmm-skills/plan/bmad-ux/SKILL.md +0 -90
  114. package/src/bmm-skills/plan/bmad-ux/assets/color-themes.md +0 -9
  115. package/src/bmm-skills/plan/bmad-ux/assets/design-directions.md +0 -9
  116. package/src/bmm-skills/plan/bmad-ux/assets/design-example-editorial.md +0 -158
  117. package/src/bmm-skills/plan/bmad-ux/assets/design-example-mobile.md +0 -93
  118. package/src/bmm-skills/plan/bmad-ux/assets/design-example-shadcn.md +0 -109
  119. package/src/bmm-skills/plan/bmad-ux/assets/excalidraw-wireframe.md +0 -19
  120. package/src/bmm-skills/plan/bmad-ux/assets/experience-example-mobile.md +0 -112
  121. package/src/bmm-skills/plan/bmad-ux/assets/experience-example-shadcn.md +0 -133
  122. package/src/bmm-skills/plan/bmad-ux/assets/headless-schemas.md +0 -84
  123. package/src/bmm-skills/plan/bmad-ux/assets/key-screens.md +0 -29
  124. package/src/bmm-skills/plan/bmad-ux/assets/validation-report-template.html +0 -319
  125. package/src/bmm-skills/plan/bmad-ux/customize.toml +0 -100
  126. package/src/bmm-skills/plan/bmad-ux/references/creative-tools.md +0 -19
  127. package/src/bmm-skills/plan/bmad-ux/references/design-md-spec.md +0 -50
  128. package/src/bmm-skills/plan/bmad-ux/references/headless.md +0 -37
  129. package/src/bmm-skills/plan/bmad-ux/references/validate.md +0 -115
  130. package/src/bmm-skills/ship/bmad-build/SKILL.md +0 -13
  131. package/src/bmm-skills/ship/bmad-build/compile-epic-context.md +0 -62
  132. package/src/bmm-skills/ship/bmad-build/customize.toml +0 -152
  133. package/src/bmm-skills/ship/bmad-build/references/claims-check.md +0 -14
  134. package/src/bmm-skills/ship/bmad-build/references/deletion-check.md +0 -14
  135. package/src/bmm-skills/ship/bmad-build/review-prompts/edge-case-hunter.md +0 -112
  136. package/src/bmm-skills/ship/bmad-build/review-prompts/verification-gap.md +0 -113
  137. package/src/bmm-skills/ship/bmad-build/spec-template.md +0 -111
  138. package/src/bmm-skills/ship/bmad-build/step-01-clarify-and-route.md +0 -100
  139. package/src/bmm-skills/ship/bmad-build/step-02-plan.md +0 -62
  140. package/src/bmm-skills/ship/bmad-build/step-03-implement.md +0 -51
  141. package/src/bmm-skills/ship/bmad-build/step-04-review.md +0 -85
  142. package/src/bmm-skills/ship/bmad-build/step-05-present.md +0 -43
  143. package/src/bmm-skills/ship/bmad-build/step-oneshot.md +0 -107
  144. package/src/bmm-skills/ship/bmad-build/sync-sprint-status.md +0 -5
  145. package/src/bmm-skills/ship/bmad-build/workflow.md +0 -84
  146. package/src/bmm-skills/ship/bmad-build-auto/SKILL.md +0 -13
  147. package/src/bmm-skills/ship/bmad-build-auto/compile-epic-context.md +0 -62
  148. package/src/bmm-skills/ship/bmad-build-auto/customize.toml +0 -119
  149. package/src/bmm-skills/ship/bmad-build-auto/references/claims-check.md +0 -14
  150. package/src/bmm-skills/ship/bmad-build-auto/references/deletion-check.md +0 -14
  151. package/src/bmm-skills/ship/bmad-build-auto/review-prompts/edge-case-hunter.md +0 -112
  152. package/src/bmm-skills/ship/bmad-build-auto/review-prompts/verification-gap.md +0 -113
  153. package/src/bmm-skills/ship/bmad-build-auto/spec-template.md +0 -96
  154. package/src/bmm-skills/ship/bmad-build-auto/step-01-clarify-and-route.md +0 -84
  155. package/src/bmm-skills/ship/bmad-build-auto/step-02-plan.md +0 -27
  156. package/src/bmm-skills/ship/bmad-build-auto/step-03-implement.md +0 -48
  157. package/src/bmm-skills/ship/bmad-build-auto/step-04-review.md +0 -116
  158. package/src/bmm-skills/ship/bmad-build-auto/workflow.md +0 -104
  159. package/src/bmm-skills/ship/bmad-code-review/SKILL.md +0 -90
  160. package/src/bmm-skills/ship/bmad-code-review/customize.toml +0 -110
  161. package/src/bmm-skills/ship/bmad-code-review/references/claims-check.md +0 -14
  162. package/src/bmm-skills/ship/bmad-code-review/references/deletion-check.md +0 -14
  163. package/src/bmm-skills/ship/bmad-code-review/review-prompts/edge-case-hunter.md +0 -112
  164. package/src/bmm-skills/ship/bmad-code-review/review-prompts/verification-gap.md +0 -113
  165. package/src/bmm-skills/ship/bmad-code-review/steps/step-01-gather-context.md +0 -94
  166. package/src/bmm-skills/ship/bmad-code-review/steps/step-02-review.md +0 -32
  167. package/src/bmm-skills/ship/bmad-code-review/steps/step-03-triage.md +0 -54
  168. package/src/bmm-skills/ship/bmad-code-review/steps/step-04-present.md +0 -134
  169. package/src/bmm-skills/ship/bmad-correct-course/SKILL.md +0 -308
  170. package/src/bmm-skills/ship/bmad-correct-course/checklist.md +0 -288
  171. package/src/bmm-skills/ship/bmad-correct-course/customize.toml +0 -39
  172. package/src/bmm-skills/ship/bmad-qa-generate-e2e-tests/SKILL.md +0 -176
  173. package/src/bmm-skills/ship/bmad-qa-generate-e2e-tests/checklist.md +0 -33
  174. package/src/bmm-skills/ship/bmad-qa-generate-e2e-tests/customize.toml +0 -39
  175. package/src/bmm-skills/ship/bmad-retrospective/SKILL.md +0 -94
  176. package/src/bmm-skills/ship/bmad-retrospective/customize.toml +0 -39
  177. package/src/bmm-skills/ship/bmad-retrospective/references/acceptance-verdict.md +0 -55
  178. package/src/bmm-skills/ship/bmad-retrospective/references/aggregate-views.md +0 -17
  179. package/src/bmm-skills/ship/bmad-retrospective/references/evidence-gathering.md +0 -30
  180. package/src/bmm-skills/ship/bmad-retrospective/references/retro-document.md +0 -84
  181. package/src/bmm-skills/ship/bmad-retrospective/references/team-discussion.md +0 -22
  182. package/src/bmm-skills/ship/bmad-retrospective/scripts/__pycache__/sprint_status.cpython-311.pyc +0 -0
  183. package/src/bmm-skills/ship/bmad-retrospective/scripts/git_evidence.py +0 -308
  184. package/src/bmm-skills/ship/bmad-retrospective/scripts/sprint_status.py +0 -750
  185. package/src/bmm-skills/ship/bmad-retrospective/scripts/tests/__pycache__/test_git_evidence.cpython-311-pytest-9.1.1.pyc +0 -0
  186. package/src/bmm-skills/ship/bmad-retrospective/scripts/tests/__pycache__/test_sprint_status.cpython-311-pytest-9.1.1.pyc +0 -0
  187. package/src/bmm-skills/ship/bmad-retrospective/scripts/tests/fixtures/sprint-status-template.yaml +0 -71
  188. package/src/bmm-skills/ship/bmad-retrospective/scripts/tests/test_git_evidence.py +0 -750
  189. package/src/bmm-skills/ship/bmad-retrospective/scripts/tests/test_sprint_status.py +0 -1579
  190. package/src/bmm-skills/ship/bmad-walkthrough/SKILL.md +0 -68
  191. package/src/bmm-skills/ship/bmad-walkthrough/customize.toml +0 -39
  192. package/src/bmm-skills/ship/bmad-walkthrough/generate-trail.md +0 -38
  193. package/src/bmm-skills/ship/bmad-walkthrough/step-01-orientation.md +0 -105
  194. package/src/bmm-skills/ship/bmad-walkthrough/step-02-walkthrough.md +0 -89
  195. package/src/bmm-skills/ship/bmad-walkthrough/step-03-detail-pass.md +0 -106
  196. package/src/bmm-skills/ship/bmad-walkthrough/step-04-testing.md +0 -74
  197. package/src/bmm-skills/ship/bmad-walkthrough/step-05-wrapup.md +0 -30
  198. package/src/bmm-skills/v6-shims/README.md +0 -29
  199. package/src/bmm-skills/v6-shims/bmad-checkpoint-preview/SKILL.md +0 -21
  200. package/src/bmm-skills/v6-shims/bmad-create-architecture/SKILL.md +0 -32
  201. package/src/bmm-skills/v6-shims/bmad-create-architecture/customize.toml +0 -39
  202. package/src/bmm-skills/v6-shims/bmad-create-prd/SKILL.md +0 -32
  203. package/src/bmm-skills/v6-shims/bmad-create-prd/customize.toml +0 -39
  204. package/src/bmm-skills/v6-shims/bmad-create-story/SKILL.md +0 -436
  205. package/src/bmm-skills/v6-shims/bmad-create-story/checklist.md +0 -357
  206. package/src/bmm-skills/v6-shims/bmad-create-story/customize.toml +0 -39
  207. package/src/bmm-skills/v6-shims/bmad-create-story/discover-inputs.md +0 -88
  208. package/src/bmm-skills/v6-shims/bmad-create-story/template.md +0 -49
  209. package/src/bmm-skills/v6-shims/bmad-dev-auto/SKILL.md +0 -21
  210. package/src/bmm-skills/v6-shims/bmad-dev-story/SKILL.md +0 -504
  211. package/src/bmm-skills/v6-shims/bmad-dev-story/checklist.md +0 -80
  212. package/src/bmm-skills/v6-shims/bmad-dev-story/customize.toml +0 -39
  213. package/src/bmm-skills/v6-shims/bmad-document-project/SKILL.md +0 -16
  214. package/src/bmm-skills/v6-shims/bmad-domain-research/SKILL.md +0 -16
  215. package/src/bmm-skills/v6-shims/bmad-edit-prd/SKILL.md +0 -32
  216. package/src/bmm-skills/v6-shims/bmad-edit-prd/customize.toml +0 -40
  217. package/src/bmm-skills/v6-shims/bmad-market-research/SKILL.md +0 -16
  218. package/src/bmm-skills/v6-shims/bmad-quick-dev/SKILL.md +0 -21
  219. package/src/bmm-skills/v6-shims/bmad-sprint-status/SKILL.md +0 -28
  220. package/src/bmm-skills/v6-shims/bmad-sprint-status/customize.toml +0 -39
  221. package/src/bmm-skills/v6-shims/bmad-technical-research/SKILL.md +0 -16
  222. package/src/bmm-skills/v6-shims/bmad-validate-prd/SKILL.md +0 -32
  223. package/src/bmm-skills/v6-shims/bmad-validate-prd/customize.toml +0 -40
  224. package/src/core-skills/bmad-advanced-elicitation/SKILL.md +0 -64
  225. package/src/core-skills/bmad-advanced-elicitation/assets/methods.csv +0 -72
  226. package/src/core-skills/bmad-advanced-elicitation/customize.toml +0 -54
  227. package/src/core-skills/bmad-advanced-elicitation/scripts/pick_methods.py +0 -233
  228. package/src/core-skills/bmad-advanced-elicitation/scripts/tests/test_pick_methods.py +0 -228
  229. package/src/core-skills/bmad-brainstorming/SKILL.md +0 -80
  230. package/src/core-skills/bmad-brainstorming/assets/brain-icons.json +0 -166
  231. package/src/core-skills/bmad-brainstorming/assets/brain-methods.csv +0 -109
  232. package/src/core-skills/bmad-brainstorming/assets/brain-selector.html +0 -328
  233. package/src/core-skills/bmad-brainstorming/customize.toml +0 -83
  234. package/src/core-skills/bmad-brainstorming/references/converge.md +0 -24
  235. package/src/core-skills/bmad-brainstorming/references/finalize.md +0 -26
  236. package/src/core-skills/bmad-brainstorming/references/headless.md +0 -54
  237. package/src/core-skills/bmad-brainstorming/references/in-chat-techniques.md +0 -18
  238. package/src/core-skills/bmad-brainstorming/references/mode-autonomous.md +0 -10
  239. package/src/core-skills/bmad-brainstorming/references/mode-facilitator.md +0 -11
  240. package/src/core-skills/bmad-brainstorming/references/mode-partner.md +0 -16
  241. package/src/core-skills/bmad-brainstorming/references/resume.md +0 -5
  242. package/src/core-skills/bmad-brainstorming/scripts/brain.py +0 -789
  243. package/src/core-skills/bmad-brainstorming/scripts/tests/test_brain.py +0 -289
  244. package/src/core-skills/bmad-customize/SKILL.md +0 -111
  245. package/src/core-skills/bmad-customize/scripts/list_customizable_skills.py +0 -235
  246. package/src/core-skills/bmad-customize/scripts/tests/test_list_customizable_skills.py +0 -249
  247. package/src/core-skills/bmad-deep-recon/SKILL.md +0 -82
  248. package/src/core-skills/bmad-deep-recon/assets/research.template.md +0 -18
  249. package/src/core-skills/bmad-deep-recon/customize.toml +0 -212
  250. package/src/core-skills/bmad-deep-recon/references/draft.md +0 -8
  251. package/src/core-skills/bmad-deep-recon/references/finalize.md +0 -11
  252. package/src/core-skills/bmad-deep-recon/references/html-briefing.md +0 -16
  253. package/src/core-skills/bmad-deep-recon/references/lifecycle.md +0 -11
  254. package/src/core-skills/bmad-deep-recon/references/process.md +0 -10
  255. package/src/core-skills/bmad-deep-recon/references/run.md +0 -73
  256. package/src/core-skills/bmad-deep-recon/references/selection.md +0 -13
  257. package/src/core-skills/bmad-deep-recon/references/synthesis.md +0 -16
  258. package/src/core-skills/bmad-deep-recon/references/verification.md +0 -29
  259. package/src/core-skills/bmad-deep-recon/scripts/recon_kit.py +0 -326
  260. package/src/core-skills/bmad-deep-recon/scripts/tests/test_recon_kit.py +0 -144
  261. package/src/core-skills/bmad-deep-recon/types/academic-lit.md +0 -19
  262. package/src/core-skills/bmad-deep-recon/types/competitive.md +0 -19
  263. package/src/core-skills/bmad-deep-recon/types/domain.md +0 -19
  264. package/src/core-skills/bmad-deep-recon/types/market.md +0 -19
  265. package/src/core-skills/bmad-deep-recon/types/technical.md +0 -19
  266. package/src/core-skills/bmad-deep-recon/types/user-voice.md +0 -19
  267. package/src/core-skills/bmad-forge-idea/SKILL.md +0 -107
  268. package/src/core-skills/bmad-forge-idea/customize.toml +0 -41
  269. package/src/core-skills/bmad-forge-idea/scripts/resolve_personas.py +0 -277
  270. package/src/core-skills/bmad-forge-idea/scripts/tests/test_resolve_personas.py +0 -160
  271. package/src/core-skills/bmad-help/SKILL.md +0 -77
  272. package/src/core-skills/bmad-party-mode/SKILL.md +0 -60
  273. package/src/core-skills/bmad-party-mode/customize.toml +0 -211
  274. package/src/core-skills/bmad-party-mode/references/create-party.md +0 -70
  275. package/src/core-skills/bmad-party-mode/references/mode-agent-team.md +0 -13
  276. package/src/core-skills/bmad-party-mode/references/mode-auto.md +0 -13
  277. package/src/core-skills/bmad-party-mode/references/mode-subagent.md +0 -31
  278. package/src/core-skills/bmad-party-mode/references/party-memory.md +0 -51
  279. package/src/core-skills/bmad-party-mode/scripts/resolve_party.py +0 -300
  280. package/src/core-skills/bmad-party-mode/scripts/tests/test_resolve_party.py +0 -183
  281. package/src/core-skills/bmad-review/SKILL.md +0 -50
  282. package/src/core-skills/bmad-review/customize.toml +0 -141
  283. package/src/core-skills/bmad-review/references/editorial-common.md +0 -56
  284. package/src/core-skills/bmad-review/references/lens-adversarial.md +0 -19
  285. package/src/core-skills/bmad-review/references/lens-edge-case-hunter.md +0 -72
  286. package/src/core-skills/bmad-review/references/lens-prose.md +0 -7
  287. package/src/core-skills/bmad-review/references/lens-structure.md +0 -9
  288. package/src/core-skills/bmad-review/references/lens-verification-gap.md +0 -92
  289. package/src/core-skills/bmad-review/references/structure-models.md +0 -44
  290. package/src/core-skills/bmad-review/scripts/tests/test_word_metrics.py +0 -62
  291. package/src/core-skills/bmad-review/scripts/word_metrics.py +0 -102
  292. package/src/core-skills/module-help.csv +0 -10
  293. package/src/core-skills/module.yaml +0 -38
  294. package/src/core-skills/v6-shims/README.md +0 -25
  295. package/src/core-skills/v6-shims/bmad-editorial-review/SKILL.md +0 -8
  296. package/src/core-skills/v6-shims/bmad-editorial-review/customize.toml +0 -31
  297. package/src/core-skills/v6-shims/bmad-editorial-review-prose/SKILL.md +0 -8
  298. package/src/core-skills/v6-shims/bmad-editorial-review-structure/SKILL.md +0 -8
  299. package/src/core-skills/v6-shims/bmad-review-adversarial-general/SKILL.md +0 -8
  300. package/src/core-skills/v6-shims/bmad-review-edge-case-hunter/SKILL.md +0 -8
  301. package/src/core-skills/v6-shims/bmad-review-verification-gap/SKILL.md +0 -8
  302. package/src/scripts/__pycache__/config_utils.cpython-311.pyc +0 -0
  303. package/src/scripts/config_utils.py +0 -119
  304. package/src/scripts/memlog.py +0 -228
  305. package/src/scripts/render_skill.py +0 -401
  306. package/src/scripts/resolve_config.py +0 -82
  307. package/src/scripts/resolve_customization.py +0 -164
  308. package/src/scripts/tests/__pycache__/test_config_utils.cpython-311.pyc +0 -0
  309. package/src/scripts/tests/__pycache__/test_resolve_config.cpython-311.pyc +0 -0
  310. package/src/scripts/tests/__pycache__/test_resolve_customization.cpython-311.pyc +0 -0
  311. package/src/scripts/tests/test_config_utils.py +0 -85
  312. package/src/scripts/tests/test_memlog.py +0 -306
  313. package/src/scripts/tests/test_resolve_config.py +0 -117
  314. package/src/scripts/tests/test_resolve_customization.py +0 -179
  315. package/tools/bundle-web-bundles.js +0 -117
  316. package/tools/format-workflow-md.js +0 -263
  317. package/tools/installer/README.md +0 -60
  318. package/tools/installer/bmad-cli.js +0 -105
  319. package/tools/installer/cli-utils.js +0 -57
  320. package/tools/installer/commands/install.js +0 -151
  321. package/tools/installer/commands/status.js +0 -65
  322. package/tools/installer/commands/uninstall.js +0 -167
  323. package/tools/installer/core/config.js +0 -76
  324. package/tools/installer/core/existing-install.js +0 -121
  325. package/tools/installer/core/install-paths.js +0 -132
  326. package/tools/installer/core/installer.js +0 -1826
  327. package/tools/installer/core/legacy-warnings.js +0 -151
  328. package/tools/installer/core/manifest-generator.js +0 -883
  329. package/tools/installer/core/manifest.js +0 -439
  330. package/tools/installer/core/shim-policy.js +0 -159
  331. package/tools/installer/core/uv-check.js +0 -195
  332. package/tools/installer/core/wsl-node-check.js +0 -109
  333. package/tools/installer/file-ops.js +0 -204
  334. package/tools/installer/fs-native.js +0 -116
  335. package/tools/installer/ide/_config-driven.js +0 -972
  336. package/tools/installer/ide/manager.js +0 -324
  337. package/tools/installer/ide/platform-codes.js +0 -80
  338. package/tools/installer/ide/platform-codes.yaml +0 -363
  339. package/tools/installer/ide/shared/installed-skills.js +0 -50
  340. package/tools/installer/ide/shared/path-utils.js +0 -219
  341. package/tools/installer/ide/shared/skill-manifest.js +0 -57
  342. package/tools/installer/install-messages.yaml +0 -44
  343. package/tools/installer/list-options.js +0 -210
  344. package/tools/installer/message-loader.js +0 -83
  345. package/tools/installer/modules/channel-plan.js +0 -216
  346. package/tools/installer/modules/channel-resolver.js +0 -241
  347. package/tools/installer/modules/custom-module-manager.js +0 -924
  348. package/tools/installer/modules/external-manager.js +0 -673
  349. package/tools/installer/modules/git-env.js +0 -47
  350. package/tools/installer/modules/module-help-schema.js +0 -13
  351. package/tools/installer/modules/official-modules.js +0 -2289
  352. package/tools/installer/modules/plugin-resolver.js +0 -398
  353. package/tools/installer/modules/version-resolver.js +0 -336
  354. package/tools/installer/project-root.js +0 -224
  355. package/tools/installer/prompts.js +0 -804
  356. package/tools/installer/set-overrides.js +0 -330
  357. package/tools/installer/ui.js +0 -2262
  358. package/tools/installer/yaml-format.js +0 -245
  359. package/tools/javascript-conventions.md +0 -5
  360. package/tools/migrate-custom-module-paths.js +0 -124
  361. package/tools/skill-validator.md +0 -312
  362. package/tools/tests/__pycache__/test_validate_skills.cpython-311.pyc +0 -0
  363. package/tools/tests/fixtures/validate-skills/bmad/SKILL.md +0 -8
  364. package/tools/tests/fixtures/validate-skills/deprecated-shim/SKILL.md +0 -9
  365. package/tools/tests/fixtures/validate-skills/missing-trigger/SKILL.md +0 -9
  366. package/tools/tests/fixtures/validate-skills/with-trigger/SKILL.md +0 -8
  367. package/tools/tests/test_validate_skills.py +0 -476
  368. package/tools/validate-published-implementation-model.mjs +0 -59
  369. package/tools/validate-sidebar-order.js +0 -388
  370. package/tools/validate-svg-changes.sh +0 -356
  371. package/tools/validate_skills.py +0 -698
  372. package/web-bundles/README.md +0 -46
  373. package/web-bundles/brainstorming-coach/INSTRUCTIONS.md +0 -86
  374. package/web-bundles/brainstorming-coach/SKILL.md +0 -83
  375. package/web-bundles/brainstorming-coach/brain-methods.csv +0 -62
  376. package/web-bundles/bundles.json +0 -139
  377. package/web-bundles/market-and-industry-research/INSTRUCTIONS.md +0 -88
  378. package/web-bundles/market-and-industry-research/SKILL.md +0 -59
  379. package/web-bundles/prd-coach/INSTRUCTIONS.md +0 -86
  380. package/web-bundles/prd-coach/SKILL.md +0 -101
  381. package/web-bundles/prd-coach/prd-template.md +0 -165
  382. package/web-bundles/prd-coach/prd-validation-checklist.md +0 -135
  383. package/web-bundles/prfaq-coach/INSTRUCTIONS.md +0 -86
  384. package/web-bundles/prfaq-coach/SKILL.md +0 -139
  385. package/web-bundles/product-brief-coach/INSTRUCTIONS.md +0 -86
  386. package/web-bundles/product-brief-coach/SKILL.md +0 -113
  387. package/web-bundles/ux-coach/INSTRUCTIONS.md +0 -92
  388. package/web-bundles/ux-coach/SKILL.md +0 -187
  389. package/web-bundles/ux-coach/ux-validation.md +0 -100
@@ -1,2262 +0,0 @@
1
- const path = require('node:path');
2
- const os = require('node:os');
3
- const semver = require('semver');
4
- const fs = require('./fs-native');
5
- const installerPackageJson = require('../../package.json');
6
- const { CLIUtils } = require('./cli-utils');
7
- const { ExternalModuleManager } = require('./modules/external-manager');
8
- const { resolveModuleVersion } = require('./modules/version-resolver');
9
- const { Manifest } = require('./core/manifest');
10
- const {
11
- parseChannelOptions,
12
- buildPlan,
13
- decideChannelForModule,
14
- orphanPinWarnings,
15
- bundledTargetWarnings,
16
- } = require('./modules/channel-plan');
17
- const channelResolver = require('./modules/channel-resolver');
18
- const prompts = require('./prompts');
19
- const { parseSetEntries } = require('./set-overrides');
20
- const { inferShimPreference, readInstalledSkillIds } = require('./core/shim-policy');
21
-
22
- const manifest = new Manifest();
23
-
24
- /**
25
- * Format a resolved version for display in installer labels.
26
- * Semver-like values are normalized to a single leading "v".
27
- * @param {string|null|undefined} version
28
- * @returns {string}
29
- */
30
- function formatDisplayVersion(version) {
31
- const trimmed = typeof version === 'string' ? version.trim() : '';
32
- if (!trimmed) return '';
33
-
34
- const normalized = semver.valid(semver.coerce(trimmed));
35
- if (normalized) {
36
- return `v${normalized}`;
37
- }
38
-
39
- return trimmed;
40
- }
41
-
42
- /**
43
- * Build the display label for a module, showing an upgrade arrow when an
44
- * installed semver differs from the latest resolvable semver.
45
- * @param {string} name
46
- * @param {string} latestVersion
47
- * @param {string} installedVersion
48
- * @returns {string}
49
- */
50
- function buildModuleLabel(name, latestVersion, installedVersion = '') {
51
- const latestDisplay = formatDisplayVersion(latestVersion);
52
- if (!latestDisplay) return name;
53
-
54
- const installedDisplay = formatDisplayVersion(installedVersion);
55
- const latestSemver = semver.valid(semver.coerce(latestVersion || ''));
56
- const installedSemver = semver.valid(semver.coerce(installedVersion || ''));
57
-
58
- if (installedDisplay && latestSemver && installedSemver && semver.neq(installedSemver, latestSemver)) {
59
- return `${name} (${installedDisplay} → ${latestDisplay})`;
60
- }
61
-
62
- return `${name} (${latestDisplay})`;
63
- }
64
-
65
- /**
66
- * Resolve the version to show for a module picker entry. External modules use
67
- * the same channel/tag resolver as installs; bundled modules fall back to local
68
- * source metadata.
69
- * @param {string} moduleCode - Module code (e.g., 'core', 'bmm', 'cis')
70
- * @param {Object} options
71
- * @param {string|null} [options.repoUrl] - Module repository URL for tag resolution
72
- * @param {string|null} [options.registryDefault] - Registry default channel
73
- * @param {string|null} [options.registryPin] - Registry pinned tag
74
- * @param {Object|null} [options.channelOptions] - Parsed installer channel options
75
- * @returns {Promise<{version: string, lookupAttempted: boolean, lookupSucceeded: boolean}>}
76
- */
77
- async function getModuleVersion(moduleCode, { repoUrl = null, registryDefault = null, registryPin = null, channelOptions = null } = {}) {
78
- if (repoUrl) {
79
- const plan = decideChannelForModule({
80
- code: moduleCode,
81
- channelOptions,
82
- registryDefault,
83
- registryPin,
84
- });
85
-
86
- try {
87
- const resolved = await channelResolver.resolveChannel({
88
- channel: plan.channel,
89
- pin: plan.pin,
90
- repoUrl,
91
- });
92
- if (resolved?.version) {
93
- return {
94
- version: resolved.version,
95
- lookupAttempted: plan.channel === 'stable',
96
- lookupSucceeded: true,
97
- };
98
- }
99
- } catch {
100
- // Fall back to local metadata when tag resolution is unavailable.
101
- }
102
- }
103
-
104
- const versionInfo = await resolveModuleVersion(moduleCode);
105
- return {
106
- version: versionInfo.version || '',
107
- lookupAttempted: !!repoUrl,
108
- lookupSucceeded: false,
109
- };
110
- }
111
-
112
- /**
113
- * UI utilities for the installer
114
- */
115
- class UI {
116
- async _selectShimPreference({ selectedModules, bmadDir, existing, options, channelOptions, quickUpdate = false }) {
117
- const { OfficialModules } = require('./modules/official-modules');
118
- const officialModules = new OfficialModules({ channelOptions });
119
- const availableShims = await officialModules.discoverShims(selectedModules, { channelOptions });
120
-
121
- // The prompt is capability-driven. Once the last shim leaves the incoming
122
- // release this becomes an ordinary empty set, regardless of old state.
123
- if (availableShims.length === 0) return;
124
-
125
- const previousManifest = existing ? await manifest.read(bmadDir) : null;
126
- const installedSkillIds = existing ? await readInstalledSkillIds(bmadDir) : new Set();
127
- const currentValue = inferShimPreference({
128
- requested: options.shims,
129
- persisted: previousManifest?.installShims,
130
- availableShims,
131
- installedSkillIds,
132
- existing,
133
- });
134
-
135
- if (typeof options.shims === 'boolean' || options.yes) return currentValue;
136
-
137
- // clack's confirm never resolves without a TTY: a scripted run would exit mid-install.
138
- if (!process.stdin.isTTY) return currentValue;
139
-
140
- // Nothing to give up, so nothing to ask on every single update.
141
- if (quickUpdate && !currentValue) return currentValue;
142
-
143
- const verb = currentValue ? 'Keep' : 'Install';
144
- const message =
145
- `${verb} ${availableShims.length} deprecated compatibility shim skill(s)? Recommended: No. ` +
146
- `If you say yes, the deprecated skills will exist as a skill that forwards to its replacement skill. ` +
147
- `Shims will be removed with v7. You should only retain if you customized a shimmed skill and need to ` +
148
- `still transition it to the replacement.`;
149
-
150
- return prompts.confirm({ message, default: currentValue });
151
- }
152
-
153
- /**
154
- * Warn once for each selected module the registry marks deprecated.
155
- *
156
- * A deprecated module is never dropped from the selection — an existing
157
- * install keeps working and keeps being updated on request. The warning is
158
- * the only behavior change, and it is what tells CLI users (`--modules`,
159
- * `--yes`) what the interactive picker shows as an option hint.
160
- *
161
- * @param {Array<string>} selectedModules - Module codes about to be installed
162
- * @returns {Promise<Array<string>>} The deprecated codes that were warned about
163
- */
164
- async _warnDeprecatedModules(selectedModules = []) {
165
- const externalManager = new ExternalModuleManager();
166
- let registryModules;
167
- try {
168
- registryModules = await externalManager.listAvailable();
169
- } catch {
170
- return []; // Registry unreadable — never block an install over a notice.
171
- }
172
-
173
- const deprecatedByCode = new Map();
174
- for (const mod of registryModules) {
175
- if (!mod.deprecated) continue;
176
- deprecatedByCode.set(mod.code, mod);
177
- for (const alias of mod.aliases) deprecatedByCode.set(alias, mod);
178
- }
179
-
180
- const warned = [];
181
- for (const code of selectedModules) {
182
- const mod = deprecatedByCode.get(code);
183
- if (!mod || warned.includes(mod.code)) continue;
184
- warned.push(mod.code);
185
- const detail = mod.deprecationMessage || 'It is no longer receiving updates.';
186
- await prompts.log.warn(`${mod.name} (${mod.code}) is deprecated. ${detail}`);
187
- }
188
- return warned;
189
- }
190
-
191
- async _retainUnavailableInstalledModules(selectedModules, installedModuleIds, bmadDir, options = {}) {
192
- const { OfficialModules } = require('./modules/official-modules');
193
- const officialCodes = new Set(['core']);
194
-
195
- const builtInModules = (await new OfficialModules().listAvailable()).modules || [];
196
- for (const mod of builtInModules) {
197
- officialCodes.add(mod.id);
198
- }
199
-
200
- const externalManager = new ExternalModuleManager();
201
- const registryModules = await externalManager.listAvailable();
202
- for (const mod of registryModules) {
203
- officialCodes.add(mod.code);
204
- }
205
-
206
- const { CustomModuleManager } = require('./modules/custom-module-manager');
207
- const customMgr = new CustomModuleManager();
208
- const selectedSet = new Set(selectedModules);
209
- const preserveModules = [];
210
-
211
- for (const moduleId of installedModuleIds) {
212
- if (moduleId === 'core') continue;
213
- if (!selectedSet.has(moduleId) && !options.preserveUnselected) continue;
214
- // Resolve a possibly-renamed module code (e.g. `bauto` -> `bmad-loop`)
215
- // before checking availability, so a registry rename doesn't freeze
216
- // the install here the way it would have prior to the alias support
217
- // in ExternalModuleManager.getModuleByCode().
218
- const canonicalId = await externalManager.resolveCanonicalCode(moduleId);
219
- if (officialCodes.has(canonicalId)) continue;
220
-
221
- const customSource = await customMgr.findModuleSourceByCode(moduleId, { bmadDir });
222
- if (!customSource) {
223
- preserveModules.push(moduleId);
224
- }
225
- }
226
-
227
- const preservedSet = new Set(preserveModules);
228
- return {
229
- selectedModules: selectedModules.filter((moduleId) => !preservedSet.has(moduleId)),
230
- preserveModules,
231
- };
232
- }
233
-
234
- /**
235
- * Prompt for installation configuration
236
- * @param {Object} options - Command-line options from install command
237
- * @returns {Object} Installation configuration
238
- */
239
- async promptInstall(options = {}) {
240
- await CLIUtils.displayLogo();
241
-
242
- // Display version-specific start message from install-messages.yaml
243
- const { MessageLoader } = require('./message-loader');
244
- const messageLoader = new MessageLoader();
245
- await messageLoader.displayStartMessage();
246
-
247
- // Probe for `uv` before any other prompts: it's the runner for the Python
248
- // scripts BMAD skills shell out to (`uv run <script>`), and uv provisions
249
- // the interpreter itself, so it's the single thing worth checking for.
250
- // As of v6.11.0 `bmad-build` and `bmad-build-auto` HALT without it.
251
- //
252
- // Still warn-don't-block, with no ack prompt: core-only, docs-only, and
253
- // CI installs never touch a rendered skill, so a missing `uv` must not
254
- // fail the run. `installer.js` repeats the warning in the post-install
255
- // summary so it survives the scrollback. The installer runs in the
256
- // destination environment, so probing PATH here tests the right machine.
257
- const { checkUvEnvironment } = require('./core/uv-check');
258
- await checkUvEnvironment();
259
-
260
- // Parse channel flags (--channel/--all-*/--next=/--pin) once. Warnings
261
- // are surfaced immediately so the user sees them before any git ops run.
262
- const channelOptions = parseChannelOptions(options);
263
- for (const warning of channelOptions.warnings) {
264
- await prompts.log.warn(warning);
265
- }
266
-
267
- // When the user launched the installer from a prerelease (npx bmad-method@next),
268
- // mirror that intent for external modules: seed the global channel to 'next' so
269
- // the module picker's version labels resolve from main HEAD (matching what
270
- // actually gets installed) and the interactive channel gate skips — the user
271
- // already declared "next" intent by typing @next. Explicit channel flags
272
- // override this seed.
273
- if (
274
- semver.prerelease(installerPackageJson.version) !== null &&
275
- !channelOptions.global &&
276
- channelOptions.nextSet.size === 0 &&
277
- channelOptions.pins.size === 0
278
- ) {
279
- channelOptions.global = 'next';
280
- await prompts.log.info(
281
- 'Launched from a prerelease — installing all external modules from main HEAD (next channel). Pass --all-stable or --pin to override.',
282
- );
283
- }
284
-
285
- // Get directory from options or prompt
286
- let confirmedDirectory;
287
- if (options.directory) {
288
- // Use provided directory from command-line
289
- const expandedDir = this.expandUserPath(options.directory);
290
- const validation = this.validateDirectorySync(expandedDir);
291
- if (validation) {
292
- throw new Error(`Invalid directory: ${validation}`);
293
- }
294
- confirmedDirectory = expandedDir;
295
- await prompts.log.info(`Using directory from command-line: ${confirmedDirectory}`);
296
- } else if (options.yes) {
297
- confirmedDirectory = process.cwd();
298
- const validation = this.validateDirectorySync(confirmedDirectory);
299
- if (validation) {
300
- throw new Error(`Invalid directory: ${validation}`);
301
- }
302
- await prompts.log.info(`Using current directory: ${confirmedDirectory}`);
303
- } else {
304
- confirmedDirectory = await this.getConfirmedDirectory();
305
- }
306
-
307
- const { Installer } = require('./core/installer');
308
- const installer = new Installer();
309
- const { bmadDir } = await installer.findBmadDir(confirmedDirectory);
310
-
311
- // Check if there's an existing BMAD installation
312
- const hasExistingInstall = await fs.pathExists(bmadDir);
313
-
314
- // Track action type (only set if there's an existing installation)
315
- let actionType;
316
-
317
- // Only show action menu if there's an existing installation
318
- if (hasExistingInstall) {
319
- // Get version information
320
- const { existingInstall, bmadDir } = await this.getExistingInstallation(confirmedDirectory);
321
-
322
- // Build menu choices dynamically
323
- const choices = [];
324
-
325
- // Always show Quick Update first (allows refreshing installation even on same version)
326
- if (existingInstall.installed) {
327
- choices.push({
328
- name: 'Quick Update',
329
- value: 'quick-update',
330
- });
331
- }
332
-
333
- // Common actions
334
- choices.push({ name: 'Modify BMAD Installation', value: 'update' });
335
-
336
- // Check if action is provided via command-line
337
- if (options.action) {
338
- const validActions = choices.map((c) => c.value);
339
- if (!validActions.includes(options.action)) {
340
- throw new Error(`Invalid action: ${options.action}. Valid actions: ${validActions.join(', ')}`);
341
- }
342
- actionType = options.action;
343
- await prompts.log.info(`Using action from command-line: ${actionType}`);
344
- } else if (options.yes) {
345
- // Default to quick-update if available, unless flags that require the
346
- // full update path are present (e.g. --custom-source which re-clones
347
- // modules at a new version — quick-update skips that entirely).
348
- if (choices.length === 0) {
349
- throw new Error('No valid actions available for this installation');
350
- }
351
- const hasQuickUpdate = choices.some((c) => c.value === 'quick-update');
352
- const needsFullUpdate = !!options.customSource || typeof options.shims === 'boolean';
353
- actionType = hasQuickUpdate && !needsFullUpdate ? 'quick-update' : (choices.find((c) => c.value === 'update') || choices[0]).value;
354
- await prompts.log.info(`Non-interactive mode (--yes): defaulting to ${actionType}`);
355
- } else {
356
- actionType = await prompts.select({
357
- message: 'How would you like to proceed?',
358
- choices: choices,
359
- default: choices[0].value,
360
- });
361
- }
362
-
363
- // Handle quick update separately
364
- if (actionType === 'quick-update') {
365
- // Quick update never shows the module picker, so this is the only
366
- // place an existing install of a deprecated module hears about it.
367
- await this._warnDeprecatedModules(existingInstall.moduleIds || []);
368
-
369
- const installShims = await this._selectShimPreference({
370
- selectedModules: existingInstall.moduleIds || [],
371
- bmadDir,
372
- existing: true,
373
- options,
374
- channelOptions,
375
- quickUpdate: true,
376
- });
377
-
378
- return {
379
- actionType: 'quick-update',
380
- directory: confirmedDirectory,
381
- skipPrompts: options.yes || false,
382
- installShims: installShims === undefined ? options.shims : installShims,
383
- };
384
- }
385
-
386
- // If actionType === 'update', handle it with the new flow
387
- // Return early with modify configuration
388
- if (actionType === 'update') {
389
- // Get existing installation info
390
- const { installedModuleIds, installedModuleVersions } = await this.getExistingInstallation(confirmedDirectory);
391
-
392
- await prompts.log.message(`Found existing modules: ${[...installedModuleIds].join(', ')}`);
393
-
394
- // Unified module selection - all modules in one grouped multiselect
395
- let selectedModules;
396
- if (options.modules) {
397
- // Use modules from command-line
398
- selectedModules = options.modules
399
- .split(',')
400
- .map((m) => m.trim())
401
- .filter(Boolean);
402
- await prompts.log.info(`Using modules from command-line: ${selectedModules.join(', ')}`);
403
- } else if (options.customSource && !options.yes) {
404
- // Custom source without --modules or --yes: start with empty list
405
- // (only custom source modules + core will be installed).
406
- // When --yes is also set, fall through to the --yes branch so all
407
- // installed modules are included alongside the custom source modules.
408
- selectedModules = [];
409
- } else if (options.yes) {
410
- selectedModules = await this.getDefaultModules(installedModuleIds);
411
- await prompts.log.info(
412
- `Non-interactive mode (--yes): using default modules (installed + defaults): ${selectedModules.join(', ')}`,
413
- );
414
- } else {
415
- selectedModules = await this.selectAllModules(installedModuleIds, installedModuleVersions, channelOptions);
416
- }
417
-
418
- // Resolve custom sources from --custom-source flag
419
- if (options.customSource) {
420
- const customCodes = await this._resolveCustomSourcesCli(options.customSource);
421
- for (const code of customCodes) {
422
- if (!selectedModules.includes(code)) selectedModules.push(code);
423
- }
424
- }
425
-
426
- // Ensure core is in the modules list
427
- if (!selectedModules.includes('core')) {
428
- selectedModules.unshift('core');
429
- }
430
-
431
- const retainedModuleResult = await this._retainUnavailableInstalledModules(selectedModules, installedModuleIds, bmadDir, {
432
- preserveUnselected: options.yes && !options.modules,
433
- });
434
- selectedModules = retainedModuleResult.selectedModules;
435
- const preservedModules = retainedModuleResult.preserveModules;
436
-
437
- if (preservedModules.length > 0) {
438
- await prompts.log.warn(
439
- `Retaining ${preservedModules.length} installed module(s) with no available source: ${preservedModules.join(', ')}`,
440
- );
441
- }
442
-
443
- // Surface deprecation notices for whatever ended up selected. The
444
- // interactive picker only hints at them in the option list, and the
445
- // --modules / --yes paths never see that list at all.
446
- await this._warnDeprecatedModules(selectedModules);
447
-
448
- // For existing installs, resolve per-module update decisions BEFORE
449
- // we clone anything. Reads the existing manifest's recorded channel
450
- // per module and prompts the user on available upgrades (patch/minor
451
- // default Y, major default N). Legacy entries with no channel are
452
- // migrated here too. Mutates channelOptions.pins to lock rejections.
453
- await this._resolveUpdateChannels({
454
- bmadDir,
455
- selectedModules,
456
- channelOptions,
457
- yes: options.yes || false,
458
- });
459
-
460
- // Get tool selection
461
- const toolSelection = await this.promptToolSelection(confirmedDirectory, options);
462
-
463
- const { moduleConfigs, setOverrides } = await this.collectModuleConfigs(confirmedDirectory, selectedModules, {
464
- ...options,
465
- channelOptions,
466
- });
467
- const installShims = await this._selectShimPreference({
468
- selectedModules,
469
- bmadDir,
470
- existing: true,
471
- options,
472
- channelOptions,
473
- });
474
-
475
- // Warn about --pin/--next flags that refer to modules the user didn't
476
- // select, or that target bundled modules (core/bmm) where channel
477
- // flags don't apply.
478
- {
479
- const bundledCodes = await this._bundledModuleCodes();
480
- for (const warning of [
481
- ...orphanPinWarnings(channelOptions, selectedModules),
482
- ...bundledTargetWarnings(channelOptions, bundledCodes),
483
- ]) {
484
- await prompts.log.warn(warning);
485
- }
486
- }
487
-
488
- return {
489
- actionType: 'update',
490
- directory: confirmedDirectory,
491
- modules: selectedModules,
492
- ides: toolSelection.ides,
493
- skipIde: toolSelection.skipIde,
494
- coreConfig: moduleConfigs.core || {},
495
- moduleConfigs: moduleConfigs,
496
- setOverrides,
497
- skipPrompts: options.yes || false,
498
- channelOptions,
499
- _preserveModules: preservedModules,
500
- installShims,
501
- };
502
- }
503
- }
504
-
505
- // This section is only for new installations (update returns early above)
506
- const { installedModuleIds, installedModuleVersions } = await this.getExistingInstallation(confirmedDirectory);
507
-
508
- // Unified module selection - all modules in one grouped multiselect
509
- let selectedModules;
510
- if (options.modules) {
511
- // Use modules from command-line
512
- selectedModules = options.modules
513
- .split(',')
514
- .map((m) => m.trim())
515
- .filter(Boolean);
516
- await prompts.log.info(`Using modules from command-line: ${selectedModules.join(', ')}`);
517
- } else if (options.customSource) {
518
- // Custom source without --modules: start with empty list (core added below)
519
- selectedModules = [];
520
- } else if (options.yes) {
521
- // Use default modules when --yes flag is set
522
- selectedModules = await this.getDefaultModules(installedModuleIds);
523
- await prompts.log.info(`Using default modules (--yes flag): ${selectedModules.join(', ')}`);
524
- } else {
525
- selectedModules = await this.selectAllModules(installedModuleIds, installedModuleVersions, channelOptions);
526
- }
527
-
528
- // Resolve custom sources from --custom-source flag
529
- if (options.customSource) {
530
- const customCodes = await this._resolveCustomSourcesCli(options.customSource);
531
- for (const code of customCodes) {
532
- if (!selectedModules.includes(code)) selectedModules.push(code);
533
- }
534
- }
535
-
536
- // Ensure core is in the modules list
537
- if (!selectedModules.includes('core')) {
538
- selectedModules.unshift('core');
539
- }
540
-
541
- await this._warnDeprecatedModules(selectedModules);
542
-
543
- // Interactive channel gate: "Ready to install (all stable)? [Y/n]"
544
- // Only shown for fresh installs with no channel flags and an external module
545
- // selected. Skipped for prerelease launches because channelOptions.global
546
- // was already seeded to 'next' upstream. Non-interactive installs skip this
547
- // and fall through to the registry default (stable) or whatever flags were
548
- // supplied.
549
- await this._interactiveChannelGate({ options, channelOptions, selectedModules });
550
-
551
- let toolSelection = await this.promptToolSelection(confirmedDirectory, options);
552
- const { moduleConfigs, setOverrides } = await this.collectModuleConfigs(confirmedDirectory, selectedModules, {
553
- ...options,
554
- channelOptions,
555
- });
556
- const installShims = await this._selectShimPreference({
557
- selectedModules,
558
- bmadDir,
559
- existing: false,
560
- options,
561
- channelOptions,
562
- });
563
-
564
- // Warn about --pin/--next flags that refer to modules the user didn't
565
- // select, or that target bundled modules (core/bmm) where channel
566
- // flags don't apply.
567
- {
568
- const bundledCodes = await this._bundledModuleCodes();
569
- for (const warning of [
570
- ...orphanPinWarnings(channelOptions, selectedModules),
571
- ...bundledTargetWarnings(channelOptions, bundledCodes),
572
- ]) {
573
- await prompts.log.warn(warning);
574
- }
575
- }
576
-
577
- return {
578
- actionType: 'install',
579
- directory: confirmedDirectory,
580
- modules: selectedModules,
581
- ides: toolSelection.ides,
582
- skipIde: toolSelection.skipIde,
583
- coreConfig: moduleConfigs.core || {},
584
- moduleConfigs: moduleConfigs,
585
- setOverrides,
586
- skipPrompts: options.yes || false,
587
- channelOptions,
588
- installShims,
589
- };
590
- }
591
-
592
- /**
593
- * Prompt for tool/IDE selection (called after module configuration)
594
- * Uses a split prompt approach:
595
- * 1. Recommended tools - standard multiselect for preferred tools
596
- * 2. Additional tools - autocompleteMultiselect with search capability
597
- * @param {string} projectDir - Project directory to check for existing IDEs
598
- * @param {Object} options - Command-line options
599
- * @returns {Object} Tool configuration
600
- */
601
- _parseToolsFlag(toolsArg, allKnownValues) {
602
- const selectedIdes = toolsArg
603
- .split(',')
604
- .map((t) => t.trim())
605
- .filter(Boolean);
606
-
607
- if (selectedIdes.length === 0) {
608
- const err = new Error(
609
- '--tools was passed empty. Provide at least one tool ID (e.g. --tools claude-code) or run with --list-tools to see valid IDs.',
610
- );
611
- err.expected = true;
612
- throw err;
613
- }
614
-
615
- const unknown = selectedIdes.filter((id) => !allKnownValues.has(id));
616
- if (unknown.length > 0) {
617
- const err = new Error(
618
- [
619
- `Unknown tool ID${unknown.length === 1 ? '' : 's'}: ${unknown.join(', ')}`,
620
- '',
621
- 'Run with --list-tools to see all valid IDs.',
622
- 'Common: claude-code, cursor, copilot, windsurf, cline',
623
- ].join('\n'),
624
- );
625
- err.expected = true;
626
- throw err;
627
- }
628
-
629
- return selectedIdes;
630
- }
631
-
632
- async promptToolSelection(projectDir, options = {}) {
633
- const { ExistingInstall } = require('./core/existing-install');
634
- const { Installer } = require('./core/installer');
635
- const installer = new Installer();
636
- const { bmadDir } = await installer.findBmadDir(projectDir || process.cwd());
637
- const existingInstall = await ExistingInstall.detect(bmadDir);
638
- const configuredIdes = existingInstall.ides;
639
-
640
- // Get IDE manager to fetch available IDEs dynamically
641
- const { IdeManager } = require('./ide/manager');
642
- const ideManager = new IdeManager();
643
- await ideManager.ensureInitialized(); // IMPORTANT: Must initialize before getting IDEs
644
-
645
- const preferredIdes = ideManager.getPreferredIdes();
646
- const otherIdes = ideManager.getOtherIdes();
647
-
648
- // Determine which configured IDEs are in "preferred" vs "other" categories
649
- const configuredPreferred = configuredIdes.filter((id) => preferredIdes.some((ide) => ide.value === id));
650
- const configuredOther = configuredIdes.filter((id) => otherIdes.some((ide) => ide.value === id));
651
-
652
- // Warn about previously configured tools that are no longer available
653
- const allKnownValues = new Set([...preferredIdes, ...otherIdes].map((ide) => ide.value));
654
- const unknownTools = configuredIdes.filter((id) => id && typeof id === 'string' && !allKnownValues.has(id));
655
- if (unknownTools.length > 0) {
656
- await prompts.log.warn(`Previously configured tools are no longer available: ${unknownTools.join(', ')}`);
657
- }
658
-
659
- // ─────────────────────────────────────────────────────────────────────────────
660
- // UPGRADE PATH: If tools already configured, show all tools with configured at top
661
- // ─────────────────────────────────────────────────────────────────────────────
662
- if (configuredIdes.length > 0) {
663
- const allTools = [...preferredIdes, ...otherIdes];
664
-
665
- // Non-interactive: handle --tools and --yes flags before interactive prompt
666
- // Use !== undefined so an explicit --tools "" falls through to _parseToolsFlag and
667
- // gets a specific "passed empty" error instead of being silently ignored.
668
- if (options.tools !== undefined) {
669
- const selectedIdes = this._parseToolsFlag(options.tools, allKnownValues);
670
- await prompts.log.info(`Using tools from command-line: ${selectedIdes.join(', ')}`);
671
- await this.displaySelectedTools(selectedIdes, preferredIdes, allTools);
672
- return { ides: selectedIdes, skipIde: false };
673
- }
674
-
675
- if (options.yes) {
676
- await prompts.log.info(`Non-interactive mode (--yes): keeping configured tools: ${configuredIdes.join(', ')}`);
677
- await this.displaySelectedTools(configuredIdes, preferredIdes, allTools);
678
- return { ides: configuredIdes, skipIde: false };
679
- }
680
-
681
- // Sort: configured tools first, then preferred, then others
682
- const sortedTools = [
683
- ...allTools.filter((ide) => configuredIdes.includes(ide.value)),
684
- ...allTools.filter((ide) => !configuredIdes.includes(ide.value)),
685
- ];
686
-
687
- const upgradeOptions = sortedTools.map((ide) => {
688
- const isConfigured = configuredIdes.includes(ide.value);
689
- const isPreferred = preferredIdes.some((p) => p.value === ide.value);
690
- let label = ide.name;
691
- if (isPreferred) label += ' ⭐';
692
- if (isConfigured) label += ' ✅';
693
- return { label, value: ide.value };
694
- });
695
-
696
- // Sort initialValues to match display order
697
- const sortedInitialValues = sortedTools.filter((ide) => configuredIdes.includes(ide.value)).map((ide) => ide.value);
698
-
699
- const upgradeSelected = await prompts.autocompleteMultiselect({
700
- message: 'Integrate with',
701
- options: upgradeOptions,
702
- initialValues: sortedInitialValues,
703
- required: false,
704
- maxItems: 8,
705
- });
706
-
707
- const selectedIdes = upgradeSelected || [];
708
-
709
- if (selectedIdes.length === 0) {
710
- const confirmNoTools = await prompts.confirm({
711
- message: 'No tools selected. Continue without installing any tools?',
712
- default: false,
713
- });
714
-
715
- if (!confirmNoTools) {
716
- return this.promptToolSelection(projectDir, options);
717
- }
718
-
719
- return { ides: [], skipIde: true };
720
- }
721
-
722
- // Display selected tools
723
- await this.displaySelectedTools(selectedIdes, preferredIdes, allTools);
724
-
725
- return { ides: selectedIdes, skipIde: false };
726
- }
727
-
728
- // ─────────────────────────────────────────────────────────────────────────────
729
- // NEW INSTALL: Show all tools with search
730
- // ─────────────────────────────────────────────────────────────────────────────
731
- const allTools = [...preferredIdes, ...otherIdes];
732
-
733
- const allToolOptions = allTools.map((ide) => {
734
- const isPreferred = preferredIdes.some((p) => p.value === ide.value);
735
- let label = ide.name;
736
- if (isPreferred) label += ' ⭐';
737
- return {
738
- label,
739
- value: ide.value,
740
- };
741
- });
742
-
743
- let selectedIdes = [];
744
-
745
- // Check if tools are provided via command-line.
746
- // Use !== undefined so an explicit --tools "" still hits _parseToolsFlag's empty-value error.
747
- if (options.tools !== undefined) {
748
- selectedIdes = this._parseToolsFlag(options.tools, allKnownValues);
749
- await prompts.log.info(`Using tools from command-line: ${selectedIdes.join(', ')}`);
750
- await this.displaySelectedTools(selectedIdes, preferredIdes, allTools);
751
- return { ides: selectedIdes, skipIde: false };
752
- } else if (options.yes) {
753
- // If --yes flag is set, skip tool prompt and use previously configured tools or empty
754
- if (configuredIdes.length > 0) {
755
- await prompts.log.info(`Using previously configured tools (--yes flag): ${configuredIdes.join(', ')}`);
756
- await this.displaySelectedTools(configuredIdes, preferredIdes, allTools);
757
- return { ides: configuredIdes, skipIde: false };
758
- } else {
759
- const err = new Error(
760
- [
761
- '--tools is required for non-interactive install (--yes / -y) when no tools are previously configured.',
762
- '',
763
- 'Common: claude-code, cursor, copilot, windsurf, cline',
764
- 'See all supported tools: bmad-method install --list-tools',
765
- '',
766
- 'Example: bmad-method install --modules bmm --tools claude-code -y',
767
- ].join('\n'),
768
- );
769
- err.expected = true;
770
- throw err;
771
- }
772
- }
773
-
774
- // Interactive mode
775
- const interactiveSelectedIdes = await prompts.autocompleteMultiselect({
776
- message: 'Integrate with:',
777
- options: allToolOptions,
778
- initialValues: configuredIdes.length > 0 ? configuredIdes : undefined,
779
- required: false,
780
- maxItems: 8,
781
- });
782
-
783
- selectedIdes = interactiveSelectedIdes || [];
784
-
785
- // ─────────────────────────────────────────────────────────────────────────────
786
- // STEP 3: Confirm if no tools selected
787
- // ─────────────────────────────────────────────────────────────────────────────
788
- if (selectedIdes.length === 0) {
789
- const confirmNoTools = await prompts.confirm({
790
- message: 'No tools selected. Continue without installing any tools?',
791
- default: false,
792
- });
793
-
794
- if (!confirmNoTools) {
795
- // User wants to select tools - recurse
796
- return this.promptToolSelection(projectDir, options);
797
- }
798
-
799
- return {
800
- ides: [],
801
- skipIde: true,
802
- };
803
- }
804
-
805
- // Display selected tools
806
- await this.displaySelectedTools(selectedIdes, preferredIdes, allTools);
807
-
808
- return {
809
- ides: selectedIdes,
810
- skipIde: selectedIdes.length === 0,
811
- };
812
- }
813
-
814
- /**
815
- * Prompt for update configuration
816
- * @returns {Object} Update configuration
817
- */
818
- async promptUpdate() {
819
- const backupFirst = await prompts.confirm({
820
- message: 'Create backup before updating?',
821
- default: true,
822
- });
823
-
824
- const preserveCustomizations = await prompts.confirm({
825
- message: 'Preserve local customizations?',
826
- default: true,
827
- });
828
-
829
- return { backupFirst, preserveCustomizations };
830
- }
831
-
832
- /**
833
- * Confirm action
834
- * @param {string} message - Confirmation message
835
- * @param {boolean} defaultValue - Default value
836
- * @returns {boolean} User confirmation
837
- */
838
- async confirm(message, defaultValue = false) {
839
- return await prompts.confirm({
840
- message,
841
- default: defaultValue,
842
- });
843
- }
844
-
845
- /**
846
- * Get confirmed directory from user
847
- * @returns {string} Confirmed directory path
848
- */
849
- async getConfirmedDirectory() {
850
- let confirmedDirectory = null;
851
- while (!confirmedDirectory) {
852
- const directoryAnswer = await this.promptForDirectory();
853
- await this.displayDirectoryInfo(directoryAnswer.directory);
854
-
855
- if (await this.confirmDirectory(directoryAnswer.directory)) {
856
- confirmedDirectory = directoryAnswer.directory;
857
- }
858
- }
859
- return confirmedDirectory;
860
- }
861
-
862
- /**
863
- * Get existing installation info and installed modules
864
- * @param {string} directory - Installation directory
865
- * @returns {Object} Object with existingInstall, installedModuleIds, installedModuleVersions, and bmadDir
866
- */
867
- async getExistingInstallation(directory) {
868
- const { ExistingInstall } = require('./core/existing-install');
869
- const { Installer } = require('./core/installer');
870
- const installer = new Installer();
871
- const { bmadDir } = await installer.findBmadDir(directory);
872
- const existingInstall = await ExistingInstall.detect(bmadDir);
873
- const installedModuleIds = new Set(existingInstall.moduleIds);
874
- const installedModuleVersions = new Map();
875
- const manifestModules = await manifest.getAllModuleVersions(bmadDir);
876
-
877
- for (const module of manifestModules) {
878
- if (module?.name && module.version) {
879
- installedModuleVersions.set(module.name, module.version);
880
- }
881
- }
882
-
883
- for (const module of existingInstall.modules) {
884
- if (module?.id && module.version && module.version !== 'unknown' && !installedModuleVersions.has(module.id)) {
885
- installedModuleVersions.set(module.id, module.version);
886
- }
887
- }
888
-
889
- if (existingInstall.hasCore && existingInstall.version && !installedModuleVersions.has('core')) {
890
- installedModuleVersions.set('core', existingInstall.version);
891
- }
892
-
893
- return { existingInstall, installedModuleIds, installedModuleVersions, bmadDir };
894
- }
895
-
896
- /**
897
- * Collect all module configurations (core + selected modules).
898
- * All interactive prompting happens here in the UI layer.
899
- * @param {string} directory - Installation directory
900
- * @param {string[]} modules - Modules to configure (including 'core')
901
- * @param {Object} options - Command-line options
902
- * @returns {Object} Collected module configurations keyed by module name
903
- */
904
- async collectModuleConfigs(directory, modules, options = {}) {
905
- const { OfficialModules } = require('./modules/official-modules');
906
-
907
- // Parse --set up front purely to surface user-error before the install
908
- // burns time on the network / filesystem. The actual application happens
909
- // in installer.install() as a post-write TOML patch — see
910
- // `tools/installer/set-overrides.js`. We also warn about overrides
911
- // targeting modules the user didn't include, since those will silently
912
- // miss the file the patch step looks for.
913
- let setOverrides = {};
914
- try {
915
- setOverrides = parseSetEntries(options.set || []);
916
- } catch (error) {
917
- // install.js validated already; rethrow as-is for the user.
918
- throw error;
919
- }
920
- // Drop overrides for modules that aren't in the install set so the
921
- // post-install patch step doesn't create orphan sections in config.toml
922
- // for modules that were never installed.
923
- const selectedModuleSet = new Set(['core', ...modules]);
924
- for (const moduleCode of Object.keys(setOverrides)) {
925
- if (!selectedModuleSet.has(moduleCode)) {
926
- await prompts.log.warn(
927
- `--set ${moduleCode}.* — module '${moduleCode}' is not in the install set; values will be ignored. Add it to --modules to apply.`,
928
- );
929
- delete setOverrides[moduleCode];
930
- }
931
- }
932
-
933
- const configCollector = new OfficialModules({ channelOptions: options.channelOptions });
934
-
935
- const hasCoreCliOptions =
936
- options.userName || options.communicationLanguage || options.documentOutputLanguage || options.outputFolder || setOverrides.core;
937
-
938
- // Seed core config from CLI options if provided. `--set core.<key>` seeds it
939
- // too: core values are dependency-bearing — module artifact paths are built
940
- // from output_folder here, and each module's config.yaml snapshots the core
941
- // values — so the post-install patch alone lands too late.
942
- if (hasCoreCliOptions) {
943
- const coreConfig = { ...setOverrides.core };
944
- if (options.userName) {
945
- coreConfig.user_name = options.userName;
946
- await prompts.log.info(`Using user name from command-line: ${options.userName}`);
947
- }
948
- if (options.communicationLanguage) {
949
- coreConfig.communication_language = options.communicationLanguage;
950
- await prompts.log.info(`Using communication language from command-line: ${options.communicationLanguage}`);
951
- }
952
- if (options.documentOutputLanguage) {
953
- coreConfig.document_output_language = options.documentOutputLanguage;
954
- await prompts.log.info(`Using document output language from command-line: ${options.documentOutputLanguage}`);
955
- }
956
- if (options.outputFolder) {
957
- coreConfig.output_folder = options.outputFolder;
958
- await prompts.log.info(`Using output folder from command-line: ${options.outputFolder}`);
959
- }
960
-
961
- // Load existing config to merge with provided options
962
- await configCollector.loadExistingConfig(directory);
963
- const existingConfig = configCollector.existingConfig.core || {};
964
- let defaultConfig = {};
965
- if (options.yes) {
966
- let safeUsername;
967
- try {
968
- safeUsername = os.userInfo().username;
969
- } catch {
970
- safeUsername = process.env.USER || process.env.USERNAME || 'User';
971
- }
972
- defaultConfig = {
973
- user_name: safeUsername.charAt(0).toUpperCase() + safeUsername.slice(1),
974
- project_name: path.basename(directory),
975
- communication_language: 'English',
976
- document_output_language: 'English',
977
- output_folder: '_bmad-output',
978
- };
979
- }
980
- configCollector.collectedConfig.core = { ...defaultConfig, ...existingConfig, ...coreConfig };
981
-
982
- // If not all options are provided, collect the missing ones interactively (unless --yes flag)
983
- if (
984
- !options.yes &&
985
- (!options.userName || !options.communicationLanguage || !options.documentOutputLanguage || !options.outputFolder)
986
- ) {
987
- await configCollector.collectModuleConfig('core', directory, false, true);
988
- }
989
- } else if (options.yes) {
990
- // Use all defaults when --yes flag is set
991
- await configCollector.loadExistingConfig(directory);
992
- const existingConfig = configCollector.existingConfig.core || {};
993
-
994
- if (Object.keys(existingConfig).length === 0) {
995
- let safeUsername;
996
- try {
997
- safeUsername = os.userInfo().username;
998
- } catch {
999
- safeUsername = process.env.USER || process.env.USERNAME || 'User';
1000
- }
1001
- const defaultUsername = safeUsername.charAt(0).toUpperCase() + safeUsername.slice(1);
1002
- configCollector.collectedConfig.core = {
1003
- user_name: defaultUsername,
1004
- // {directory_name} default per src/core-skills/module.yaml — matches what the
1005
- // interactive flow resolves via buildQuestion()'s {directory_name} placeholder.
1006
- project_name: path.basename(directory),
1007
- communication_language: 'English',
1008
- document_output_language: 'English',
1009
- output_folder: '_bmad-output',
1010
- };
1011
- await prompts.log.info('Using default configuration (--yes flag)');
1012
- }
1013
- }
1014
-
1015
- // Collect all module configs — core is skipped if already seeded above
1016
- await configCollector.collectAllConfigurations(modules, directory, {
1017
- skipPrompts: options.yes || false,
1018
- });
1019
-
1020
- return { moduleConfigs: configCollector.collectedConfig, setOverrides };
1021
- }
1022
-
1023
- /**
1024
- * Select all modules across three tiers: official, community, and custom URL.
1025
- * @param {Set} installedModuleIds - Currently installed module IDs
1026
- * @param {Map<string, string>} installedModuleVersions - Installed module versions from the local manifest
1027
- * @param {Object|null} channelOptions - Parsed installer channel options
1028
- * @returns {Array} Selected module codes, always including core
1029
- */
1030
- async selectAllModules(installedModuleIds = new Set(), installedModuleVersions = new Map(), channelOptions = null) {
1031
- // Phase 1: Official modules
1032
- const officialSelected = await this._selectOfficialModules(installedModuleIds, installedModuleVersions, channelOptions);
1033
-
1034
- // Identify installed modules that aren't official (previously installed
1035
- // community modules or custom-source modules). Preserve them on update;
1036
- // they can be managed via --custom-source, uninstall, or a dedicated installer.
1037
- const externalManager = new ExternalModuleManager();
1038
- const registryModules = await externalManager.listAvailable();
1039
- const officialRegistryCodes = new Set(['core', 'bmm', ...registryModules.map((m) => m.code)]);
1040
- const installedNonOfficial = [...installedModuleIds].filter((id) => !officialRegistryCodes.has(id));
1041
-
1042
- // Phase 2: Custom URL modules
1043
- const customSelected = await this._addCustomUrlModules(installedModuleIds);
1044
-
1045
- const allSelected = new Set([...officialSelected, ...customSelected, ...installedNonOfficial]);
1046
-
1047
- return [...allSelected];
1048
- }
1049
-
1050
- /**
1051
- * Select official modules using autocompleteMultiselect.
1052
- * Extracted from the original selectAllModules - unchanged behavior.
1053
- * @param {Set} installedModuleIds - Currently installed module IDs
1054
- * @param {Map<string, string>} installedModuleVersions - Installed module versions from the local manifest
1055
- * @param {Object|null} channelOptions - Parsed installer channel options
1056
- * @returns {Array} Selected official module codes
1057
- */
1058
- async _selectOfficialModules(installedModuleIds = new Set(), installedModuleVersions = new Map(), channelOptions = null) {
1059
- // Built-in modules (core, bmm) come from local source, not the registry
1060
- const { OfficialModules } = require('./modules/official-modules');
1061
- const builtInModules = (await new OfficialModules().listAvailable()).modules || [];
1062
-
1063
- // External modules come from the registry (with fallback)
1064
- const externalManager = new ExternalModuleManager();
1065
- const registryModules = await externalManager.listAvailable();
1066
-
1067
- const allOptions = [];
1068
- const initialValues = [];
1069
-
1070
- const buildModuleEntry = async (code, name, description, isDefault, repoUrl = null, registryDefault = null, registryPin = null) => {
1071
- const isInstalled = installedModuleIds.has(code);
1072
- const installedVersion = installedModuleVersions.get(code) || '';
1073
- const versionState = await getModuleVersion(code, { repoUrl, registryDefault, registryPin, channelOptions });
1074
- const label = buildModuleLabel(name, versionState.version, installedVersion);
1075
- return {
1076
- label,
1077
- value: code,
1078
- hint: description,
1079
- selected: isInstalled || isDefault,
1080
- lookupAttempted: versionState.lookupAttempted,
1081
- lookupSucceeded: versionState.lookupSucceeded,
1082
- };
1083
- };
1084
-
1085
- // Add built-in modules first (always available regardless of network).
1086
- // core is not offered as a row: it is a dependency of every module, always
1087
- // installed, and was only ever rendered as a locked always-on checkbox.
1088
- // It is still added back to the result below.
1089
- const builtInCodes = new Set();
1090
- for (const mod of builtInModules) {
1091
- const code = mod.id;
1092
- builtInCodes.add(code);
1093
- if (code === 'core') continue;
1094
- const entry = await buildModuleEntry(code, mod.name, mod.description, mod.defaultSelected);
1095
- allOptions.push({ label: entry.label, value: entry.value, hint: entry.hint });
1096
- if (entry.selected) {
1097
- initialValues.push(code);
1098
- }
1099
- }
1100
-
1101
- // Add external registry modules (skip built-in duplicates and deprecated
1102
- // modules that are not already installed — deprecated modules stay visible
1103
- // only so existing users can continue to manage them).
1104
- const externalRegistryModules = registryModules.filter(
1105
- (mod) => !mod.builtIn && !builtInCodes.has(mod.code) && (!mod.deprecated || installedModuleIds.has(mod.code)),
1106
- );
1107
- let externalRegistryEntries = [];
1108
- if (externalRegistryModules.length > 0) {
1109
- const spinner = await prompts.spinner();
1110
- spinner.start('Checking latest module versions...');
1111
-
1112
- externalRegistryEntries = await Promise.all(
1113
- externalRegistryModules.map(async (mod) => {
1114
- const entry = await buildModuleEntry(
1115
- mod.code,
1116
- mod.name,
1117
- mod.description,
1118
- mod.defaultSelected,
1119
- mod.url || null,
1120
- mod.defaultChannel || null,
1121
- mod.pin || null,
1122
- );
1123
- if (mod.deprecated && mod.deprecationMessage) {
1124
- entry.hint = entry.hint ? `${entry.hint} — ${mod.deprecationMessage}` : mod.deprecationMessage;
1125
- }
1126
- return { code: mod.code, entry };
1127
- }),
1128
- );
1129
-
1130
- spinner.stop('Checked latest module versions.');
1131
-
1132
- const attemptedLookups = externalRegistryEntries.filter(({ entry }) => entry.lookupAttempted).length;
1133
- const successfulLookups = externalRegistryEntries.filter(({ entry }) => entry.lookupSucceeded).length;
1134
- if (attemptedLookups > 0 && successfulLookups === 0) {
1135
- await prompts.log.warn('Could not check latest module versions; showing cached/local versions.');
1136
- }
1137
- }
1138
- for (const { code, entry } of externalRegistryEntries) {
1139
- allOptions.push({ label: entry.label, value: entry.value, hint: entry.hint });
1140
- if (entry.selected) {
1141
- initialValues.push(code);
1142
- }
1143
- }
1144
-
1145
- const selected = await prompts.autocompleteMultiselect({
1146
- message: 'Select official modules to install:',
1147
- options: allOptions,
1148
- initialValues: initialValues.length > 0 ? initialValues : undefined,
1149
- // Core installs either way and is not a row here, so empty is a valid core-only install.
1150
- required: false,
1151
- emptyLabel: 'core only',
1152
- maxItems: allOptions.length,
1153
- });
1154
-
1155
- const chosen = selected ? [...selected] : [];
1156
-
1157
- if (chosen.length > 0) {
1158
- const moduleLines = chosen.map((moduleId) => {
1159
- const opt = allOptions.find((o) => o.value === moduleId);
1160
- return ` \u2022 ${opt?.label || moduleId}`;
1161
- });
1162
- await prompts.log.message('Selected official modules:\n' + moduleLines.join('\n'));
1163
- }
1164
-
1165
- // core is never shown but always installed.
1166
- return chosen.includes('core') ? chosen : ['core', ...chosen];
1167
- }
1168
-
1169
- /**
1170
- * Prompt user to install modules from custom sources (Git URLs or local paths).
1171
- * @param {Set} installedModuleIds - Currently installed module IDs
1172
- * @returns {Array} Selected custom module code strings
1173
- */
1174
- async _addCustomUrlModules(installedModuleIds = new Set()) {
1175
- const addCustom = await prompts.confirm({
1176
- message: 'Do you want to install custom or community modules (Git URL or local path)?',
1177
- default: false,
1178
- });
1179
- if (!addCustom) return [];
1180
-
1181
- const { CustomModuleManager } = require('./modules/custom-module-manager');
1182
- const customMgr = new CustomModuleManager();
1183
- const selectedModules = [];
1184
-
1185
- let addMore = true;
1186
- while (addMore) {
1187
- const sourceInput = await prompts.text({
1188
- message: 'Git URL or local path:',
1189
- placeholder: 'https://github.com/owner/repo or /path/to/module',
1190
- validate: (input) => {
1191
- if (!input || input.trim() === '') return 'Source is required';
1192
- const result = customMgr.parseSource(input.trim());
1193
- return result.isValid ? undefined : result.error;
1194
- },
1195
- });
1196
-
1197
- const s = await prompts.spinner();
1198
- s.start('Resolving source...');
1199
-
1200
- let sourceResult;
1201
- try {
1202
- sourceResult = await customMgr.resolveSource(sourceInput.trim(), { skipInstall: true, silent: true });
1203
- s.stop(sourceResult.parsed.type === 'local' ? 'Local source resolved' : 'Repository cloned');
1204
- } catch (error) {
1205
- s.error('Failed to resolve source');
1206
- await prompts.log.error(` ${error.message}`);
1207
- addMore = await prompts.confirm({ message: 'Try another source?', default: false });
1208
- continue;
1209
- }
1210
-
1211
- if (sourceResult.parsed.type === 'local') {
1212
- await prompts.log.info('LOCAL MODULE: Pointing directly at local source (changes take effect on reinstall).');
1213
- } else {
1214
- await prompts.log.warn(
1215
- 'UNVERIFIED MODULE: This module has not been reviewed by the BMad team.\n' + ' Only install modules from sources you trust.',
1216
- );
1217
- }
1218
-
1219
- // Resolve plugins based on discovery mode vs direct mode
1220
- s.start('Analyzing plugin structure...');
1221
- const allResolved = [];
1222
- const localPath = sourceResult.parsed.type === 'local' ? sourceResult.rootDir : null;
1223
-
1224
- if (sourceResult.mode === 'discovery') {
1225
- // Discovery mode: marketplace.json found, list available plugins
1226
- let plugins;
1227
- try {
1228
- plugins = await customMgr.discoverModules(sourceResult.marketplace, sourceResult.sourceUrl);
1229
- } catch (discoverError) {
1230
- s.error('Failed to discover modules');
1231
- await prompts.log.error(` ${discoverError.message}`);
1232
- addMore = await prompts.confirm({ message: 'Try another source?', default: false });
1233
- continue;
1234
- }
1235
-
1236
- const effectiveRepoPath = sourceResult.repoPath || sourceResult.rootDir;
1237
- for (const plugin of plugins) {
1238
- try {
1239
- const resolved = await customMgr.resolvePlugin(effectiveRepoPath, plugin.rawPlugin, sourceResult.sourceUrl, localPath);
1240
- if (resolved.length > 0) {
1241
- allResolved.push(...resolved);
1242
- } else {
1243
- // No skills array or empty - use plugin metadata as-is (legacy)
1244
- allResolved.push({
1245
- code: plugin.code,
1246
- name: plugin.displayName || plugin.name,
1247
- version: plugin.version,
1248
- description: plugin.description,
1249
- strategy: 0,
1250
- pluginName: plugin.name,
1251
- skillPaths: [],
1252
- });
1253
- }
1254
- } catch (resolveError) {
1255
- await prompts.log.warn(` Could not resolve ${plugin.name}: ${resolveError.message}`);
1256
- }
1257
- }
1258
- } else {
1259
- // Direct mode: no marketplace.json, scan directory for skills and resolve
1260
- const directPlugin = {
1261
- name: sourceResult.parsed.displayName || path.basename(sourceResult.rootDir),
1262
- source: '.',
1263
- skills: [],
1264
- };
1265
-
1266
- // Scan for SKILL.md directories to populate skills array
1267
- try {
1268
- const entries = await fs.readdir(sourceResult.rootDir, { withFileTypes: true });
1269
- for (const entry of entries) {
1270
- if (entry.isDirectory()) {
1271
- const skillMd = path.join(sourceResult.rootDir, entry.name, 'SKILL.md');
1272
- if (await fs.pathExists(skillMd)) {
1273
- directPlugin.skills.push(entry.name);
1274
- }
1275
- }
1276
- }
1277
- } catch (scanError) {
1278
- s.error('Failed to scan directory');
1279
- await prompts.log.error(` ${scanError.message}`);
1280
- addMore = await prompts.confirm({ message: 'Try another source?', default: false });
1281
- continue;
1282
- }
1283
-
1284
- if (directPlugin.skills.length > 0) {
1285
- try {
1286
- const resolved = await customMgr.resolvePlugin(sourceResult.rootDir, directPlugin, sourceResult.sourceUrl, localPath);
1287
- allResolved.push(...resolved);
1288
- } catch (resolveError) {
1289
- await prompts.log.warn(` Could not resolve: ${resolveError.message}`);
1290
- }
1291
- }
1292
- }
1293
- s.stop(`Found ${allResolved.length} installable module${allResolved.length === 1 ? '' : 's'}`);
1294
-
1295
- if (allResolved.length === 0) {
1296
- await prompts.log.warn('No installable modules found in this source.');
1297
- addMore = await prompts.confirm({ message: 'Try another source?', default: false });
1298
- continue;
1299
- }
1300
-
1301
- // Build multiselect choices
1302
- // Already-installed modules are pre-checked (update). New modules are unchecked (opt-in).
1303
- // Unchecking an installed module means "skip update" - removal is handled elsewhere.
1304
- const choices = allResolved.map((mod) => {
1305
- const versionStr = mod.version ? ` v${mod.version}` : '';
1306
- const skillCount = mod.skillPaths ? mod.skillPaths.length : 0;
1307
- const skillStr = skillCount > 0 ? ` (${skillCount} skill${skillCount === 1 ? '' : 's'})` : '';
1308
- const alreadyInstalled = installedModuleIds.has(mod.code);
1309
- const hint = alreadyInstalled ? 'update' : undefined;
1310
-
1311
- return {
1312
- name: `${mod.name}${versionStr}${skillStr}`,
1313
- value: mod.code,
1314
- hint,
1315
- checked: alreadyInstalled,
1316
- };
1317
- });
1318
-
1319
- // Show descriptions before the multiselect
1320
- for (const mod of allResolved) {
1321
- const versionStr = mod.version ? ` v${mod.version}` : '';
1322
- await prompts.log.info(` ${mod.name}${versionStr}\n ${mod.description}`);
1323
- }
1324
-
1325
- const selected = await prompts.multiselect({
1326
- message: 'Select modules to install:',
1327
- choices,
1328
- required: false,
1329
- });
1330
-
1331
- if (selected && selected.length > 0) {
1332
- for (const code of selected) {
1333
- selectedModules.push(code);
1334
- }
1335
- }
1336
-
1337
- addMore = await prompts.confirm({
1338
- message: 'Add another custom source?',
1339
- default: false,
1340
- });
1341
- }
1342
-
1343
- if (selectedModules.length > 0) {
1344
- await prompts.log.message('Selected custom modules:\n' + selectedModules.map((c) => ` \u2022 ${c}`).join('\n'));
1345
- }
1346
-
1347
- return selectedModules;
1348
- }
1349
-
1350
- /**
1351
- * Resolve custom sources from --custom-source CLI flag (non-interactive).
1352
- * Auto-selects all discovered modules from each source.
1353
- * @param {string} sourcesArg - Comma-separated Git URLs or local paths
1354
- * @returns {Array} Module codes from all resolved sources
1355
- */
1356
- async _resolveCustomSourcesCli(sourcesArg) {
1357
- const { CustomModuleManager } = require('./modules/custom-module-manager');
1358
- const customMgr = new CustomModuleManager();
1359
- const allCodes = [];
1360
-
1361
- const sources = sourcesArg
1362
- .split(',')
1363
- .map((s) => s.trim())
1364
- .filter(Boolean);
1365
-
1366
- for (const source of sources) {
1367
- const s = await prompts.spinner();
1368
- s.start(`Resolving ${source}...`);
1369
-
1370
- let sourceResult;
1371
- try {
1372
- sourceResult = await customMgr.resolveSource(source, { skipInstall: true, silent: true });
1373
- s.stop(sourceResult.parsed.type === 'local' ? 'Local source resolved' : 'Repository cloned');
1374
- } catch (error) {
1375
- s.error(`Failed to resolve ${source}`);
1376
- await prompts.log.error(` ${error.message}`);
1377
- continue;
1378
- }
1379
-
1380
- const s2 = await prompts.spinner();
1381
- s2.start('Analyzing plugin structure...');
1382
- const allResolved = [];
1383
- const localPath = sourceResult.parsed.type === 'local' ? sourceResult.rootDir : null;
1384
-
1385
- if (sourceResult.mode === 'discovery') {
1386
- try {
1387
- const plugins = await customMgr.discoverModules(sourceResult.marketplace, sourceResult.sourceUrl);
1388
- const effectiveRepoPath = sourceResult.repoPath || sourceResult.rootDir;
1389
- for (const plugin of plugins) {
1390
- try {
1391
- const resolved = await customMgr.resolvePlugin(effectiveRepoPath, plugin.rawPlugin, sourceResult.sourceUrl, localPath);
1392
- if (resolved.length > 0) {
1393
- allResolved.push(...resolved);
1394
- }
1395
- } catch {
1396
- // Skip unresolvable plugins
1397
- }
1398
- }
1399
- } catch (discoverError) {
1400
- s2.error('Failed to discover modules');
1401
- await prompts.log.error(` ${discoverError.message}`);
1402
- continue;
1403
- }
1404
- } else {
1405
- // Direct mode: scan for SKILL.md directories
1406
- const directPlugin = {
1407
- name: sourceResult.parsed.displayName || path.basename(sourceResult.rootDir),
1408
- source: '.',
1409
- skills: [],
1410
- };
1411
- try {
1412
- const entries = await fs.readdir(sourceResult.rootDir, { withFileTypes: true });
1413
- for (const entry of entries) {
1414
- if (entry.isDirectory()) {
1415
- const skillMd = path.join(sourceResult.rootDir, entry.name, 'SKILL.md');
1416
- if (await fs.pathExists(skillMd)) {
1417
- directPlugin.skills.push(entry.name);
1418
- }
1419
- }
1420
- }
1421
- } catch {
1422
- // Skip unreadable directories
1423
- }
1424
-
1425
- if (directPlugin.skills.length > 0) {
1426
- try {
1427
- const resolved = await customMgr.resolvePlugin(sourceResult.rootDir, directPlugin, sourceResult.sourceUrl, localPath);
1428
- allResolved.push(...resolved);
1429
- } catch {
1430
- // Skip unresolvable
1431
- }
1432
- }
1433
- }
1434
- s2.stop(`Found ${allResolved.length} module${allResolved.length === 1 ? '' : 's'}`);
1435
-
1436
- for (const mod of allResolved) {
1437
- allCodes.push(mod.code);
1438
- const versionStr = mod.version ? ` v${mod.version}` : '';
1439
- await prompts.log.info(` Custom module: ${mod.name}${versionStr}`);
1440
- }
1441
- }
1442
-
1443
- return allCodes;
1444
- }
1445
-
1446
- /**
1447
- * Get default modules for non-interactive mode
1448
- * @param {Set} installedModuleIds - Already installed module IDs
1449
- * @returns {Array} Default module codes
1450
- */
1451
- async getDefaultModules(installedModuleIds = new Set()) {
1452
- // Built-in modules with default_selected come from local source
1453
- const { OfficialModules } = require('./modules/official-modules');
1454
- const builtInModules = (await new OfficialModules().listAvailable()).modules || [];
1455
-
1456
- const defaultModules = [];
1457
- const seen = new Set();
1458
-
1459
- for (const mod of builtInModules) {
1460
- if (mod.defaultSelected || installedModuleIds.has(mod.id)) {
1461
- defaultModules.push(mod.id);
1462
- seen.add(mod.id);
1463
- }
1464
- }
1465
-
1466
- // Add external registry defaults
1467
- const externalManager = new ExternalModuleManager();
1468
- const registryModules = await externalManager.listAvailable();
1469
-
1470
- for (const mod of registryModules) {
1471
- if (mod.builtIn || seen.has(mod.code)) continue;
1472
- if (mod.defaultSelected || installedModuleIds.has(mod.code)) {
1473
- defaultModules.push(mod.code);
1474
- }
1475
- }
1476
-
1477
- // If no defaults found, use 'bmm' as the fallback default
1478
- if (defaultModules.length === 0) {
1479
- defaultModules.push('bmm');
1480
- }
1481
-
1482
- return defaultModules;
1483
- }
1484
-
1485
- /**
1486
- * Prompt for directory selection
1487
- * @returns {Object} Directory answer from prompt
1488
- */
1489
- async promptForDirectory() {
1490
- // Use sync validation because @clack/prompts doesn't support async validate
1491
- const directory = await prompts.directory({
1492
- message: 'Installation directory:',
1493
- default: process.cwd(),
1494
- placeholder: process.cwd(),
1495
- validate: (input) => this.validateDirectorySync(input),
1496
- });
1497
-
1498
- // Apply filter logic
1499
- let filteredDir = directory;
1500
- if (!filteredDir || filteredDir.trim() === '') {
1501
- filteredDir = process.cwd();
1502
- } else {
1503
- filteredDir = this.expandUserPath(filteredDir);
1504
- }
1505
-
1506
- return { directory: filteredDir };
1507
- }
1508
-
1509
- /**
1510
- * Display directory information
1511
- * @param {string} directory - The directory path
1512
- */
1513
- async displayDirectoryInfo(directory) {
1514
- await prompts.log.info(`Resolved installation path: ${directory}`);
1515
-
1516
- const dirExists = await fs.pathExists(directory);
1517
- if (dirExists) {
1518
- // Show helpful context about the existing path
1519
- const stats = await fs.stat(directory);
1520
- if (stats.isDirectory()) {
1521
- const files = await fs.readdir(directory);
1522
- if (files.length > 0) {
1523
- // Check for any bmad installation (any folder with _config/manifest.yaml)
1524
- const { Installer } = require('./core/installer');
1525
- const installer = new Installer();
1526
- const bmadResult = await installer.findBmadDir(directory);
1527
- const hasBmadInstall =
1528
- (await fs.pathExists(bmadResult.bmadDir)) && (await fs.pathExists(path.join(bmadResult.bmadDir, '_config', 'manifest.yaml')));
1529
-
1530
- const bmadNote = hasBmadInstall ? ` including existing BMAD installation (${path.basename(bmadResult.bmadDir)})` : '';
1531
- await prompts.log.message(`Directory exists and contains ${files.length} item(s)${bmadNote}`);
1532
- } else {
1533
- await prompts.log.message('Directory exists and is empty');
1534
- }
1535
- }
1536
- }
1537
- }
1538
-
1539
- /**
1540
- * Confirm directory selection
1541
- * @param {string} directory - The directory path
1542
- * @returns {boolean} Whether user confirmed
1543
- */
1544
- async confirmDirectory(directory) {
1545
- const dirExists = await fs.pathExists(directory);
1546
-
1547
- if (dirExists) {
1548
- const proceed = await prompts.confirm({
1549
- message: 'Install to this directory?',
1550
- default: true,
1551
- });
1552
-
1553
- if (!proceed) {
1554
- await prompts.log.warn("Let's try again with a different path.");
1555
- }
1556
-
1557
- return proceed;
1558
- } else {
1559
- // Ask for confirmation to create the directory
1560
- const create = await prompts.confirm({
1561
- message: `Create directory: ${directory}?`,
1562
- default: false,
1563
- });
1564
-
1565
- if (!create) {
1566
- await prompts.log.warn("Let's try again with a different path.");
1567
- }
1568
-
1569
- return create;
1570
- }
1571
- }
1572
-
1573
- /**
1574
- * Validate directory path for installation (sync version for clack prompts)
1575
- * @param {string} input - User input path
1576
- * @returns {string|undefined} Error message or undefined if valid
1577
- */
1578
- validateDirectorySync(input) {
1579
- // Allow empty input to use the default
1580
- if (!input || input.trim() === '') {
1581
- return; // Empty means use default, undefined = valid for clack
1582
- }
1583
-
1584
- let expandedPath;
1585
- try {
1586
- expandedPath = this.expandUserPath(input.trim());
1587
- } catch (error) {
1588
- return error.message;
1589
- }
1590
-
1591
- // Check if the path exists
1592
- const pathExists = fs.pathExistsSync(expandedPath);
1593
-
1594
- if (!pathExists) {
1595
- // Find the first existing parent directory
1596
- const existingParent = this.findExistingParentSync(expandedPath);
1597
-
1598
- if (!existingParent) {
1599
- return 'Cannot create directory: no existing parent directory found';
1600
- }
1601
-
1602
- // Check if the existing parent is writable
1603
- try {
1604
- fs.accessSync(existingParent, fs.constants.W_OK);
1605
- // Path doesn't exist but can be created - will prompt for confirmation later
1606
- return;
1607
- } catch {
1608
- // Provide a detailed error message explaining both issues
1609
- return `Directory '${expandedPath}' does not exist and cannot be created: parent directory '${existingParent}' is not writable`;
1610
- }
1611
- }
1612
-
1613
- // If it exists, validate it's a directory and writable
1614
- const stat = fs.statSync(expandedPath);
1615
- if (!stat.isDirectory()) {
1616
- return `Path exists but is not a directory: ${expandedPath}`;
1617
- }
1618
-
1619
- // Check write permissions
1620
- try {
1621
- fs.accessSync(expandedPath, fs.constants.W_OK);
1622
- } catch {
1623
- return `Directory is not writable: ${expandedPath}`;
1624
- }
1625
-
1626
- return;
1627
- }
1628
-
1629
- /**
1630
- * Validate directory path for installation (async version)
1631
- * @param {string} input - User input path
1632
- * @returns {string|true} Error message or true if valid
1633
- */
1634
- async validateDirectory(input) {
1635
- // Allow empty input to use the default
1636
- if (!input || input.trim() === '') {
1637
- return true; // Empty means use default
1638
- }
1639
-
1640
- let expandedPath;
1641
- try {
1642
- expandedPath = this.expandUserPath(input.trim());
1643
- } catch (error) {
1644
- return error.message;
1645
- }
1646
-
1647
- // Check if the path exists
1648
- const pathExists = await fs.pathExists(expandedPath);
1649
-
1650
- if (!pathExists) {
1651
- // Find the first existing parent directory
1652
- const existingParent = await this.findExistingParent(expandedPath);
1653
-
1654
- if (!existingParent) {
1655
- return 'Cannot create directory: no existing parent directory found';
1656
- }
1657
-
1658
- // Check if the existing parent is writable
1659
- try {
1660
- await fs.access(existingParent, fs.constants.W_OK);
1661
- // Path doesn't exist but can be created - will prompt for confirmation later
1662
- return true;
1663
- } catch {
1664
- // Provide a detailed error message explaining both issues
1665
- return `Directory '${expandedPath}' does not exist and cannot be created: parent directory '${existingParent}' is not writable`;
1666
- }
1667
- }
1668
-
1669
- // If it exists, validate it's a directory and writable
1670
- const stat = await fs.stat(expandedPath);
1671
- if (!stat.isDirectory()) {
1672
- return `Path exists but is not a directory: ${expandedPath}`;
1673
- }
1674
-
1675
- // Check write permissions
1676
- try {
1677
- await fs.access(expandedPath, fs.constants.W_OK);
1678
- } catch {
1679
- return `Directory is not writable: ${expandedPath}`;
1680
- }
1681
-
1682
- return true;
1683
- }
1684
-
1685
- /**
1686
- * Find the first existing parent directory (sync version)
1687
- * @param {string} targetPath - The path to check
1688
- * @returns {string|null} The first existing parent directory, or null if none found
1689
- */
1690
- findExistingParentSync(targetPath) {
1691
- let currentPath = path.resolve(targetPath);
1692
-
1693
- // Walk up the directory tree until we find an existing directory
1694
- while (currentPath !== path.dirname(currentPath)) {
1695
- // Stop at root
1696
- const parent = path.dirname(currentPath);
1697
- if (fs.pathExistsSync(parent)) {
1698
- return parent;
1699
- }
1700
- currentPath = parent;
1701
- }
1702
-
1703
- return null; // No existing parent found (shouldn't happen in practice)
1704
- }
1705
-
1706
- /**
1707
- * Find the first existing parent directory (async version)
1708
- * @param {string} targetPath - The path to check
1709
- * @returns {string|null} The first existing parent directory, or null if none found
1710
- */
1711
- async findExistingParent(targetPath) {
1712
- let currentPath = path.resolve(targetPath);
1713
-
1714
- // Walk up the directory tree until we find an existing directory
1715
- while (currentPath !== path.dirname(currentPath)) {
1716
- // Stop at root
1717
- const parent = path.dirname(currentPath);
1718
- if (await fs.pathExists(parent)) {
1719
- return parent;
1720
- }
1721
- currentPath = parent;
1722
- }
1723
-
1724
- return null; // No existing parent found (shouldn't happen in practice)
1725
- }
1726
-
1727
- /**
1728
- * Expands the user-provided path: handles ~ and resolves to absolute.
1729
- * @param {string} inputPath - User input path.
1730
- * @returns {string} Absolute expanded path.
1731
- */
1732
- expandUserPath(inputPath) {
1733
- if (typeof inputPath !== 'string') {
1734
- throw new TypeError('Path must be a string.');
1735
- }
1736
-
1737
- let expanded = inputPath.trim();
1738
-
1739
- // Handle tilde expansion
1740
- if (expanded.startsWith('~')) {
1741
- if (expanded === '~') {
1742
- expanded = os.homedir();
1743
- } else if (expanded.startsWith('~' + path.sep)) {
1744
- const pathAfterHome = expanded.slice(2); // Remove ~/ or ~\
1745
- expanded = path.join(os.homedir(), pathAfterHome);
1746
- } else {
1747
- const restOfPath = expanded.slice(1);
1748
- const separatorIndex = restOfPath.indexOf(path.sep);
1749
- const username = separatorIndex === -1 ? restOfPath : restOfPath.slice(0, separatorIndex);
1750
- if (username) {
1751
- throw new Error(`Path expansion for ~${username} is not supported. Please use an absolute path or ~${path.sep}`);
1752
- }
1753
- }
1754
- }
1755
-
1756
- // Resolve to the absolute path relative to the current working directory
1757
- return path.resolve(expanded);
1758
- }
1759
-
1760
- /**
1761
- * Get configured IDEs from existing installation
1762
- * @param {string} directory - Installation directory
1763
- * @returns {Array} List of configured IDEs
1764
- */
1765
- async getConfiguredIdes(directory) {
1766
- const { ExistingInstall } = require('./core/existing-install');
1767
- const { Installer } = require('./core/installer');
1768
- const installer = new Installer();
1769
- const { bmadDir } = await installer.findBmadDir(directory);
1770
- const existingInstall = await ExistingInstall.detect(bmadDir);
1771
- return existingInstall.ides;
1772
- }
1773
-
1774
- /**
1775
- * Display module versions with update availability
1776
- * @param {Array} modules - Array of module info objects with version info
1777
- * @param {Array} availableUpdates - Array of available updates
1778
- */
1779
- async displayModuleVersions(modules, availableUpdates = []) {
1780
- // Group modules by source
1781
- const builtIn = modules.filter((m) => m.source === 'built-in');
1782
- const external = modules.filter((m) => m.source === 'external');
1783
- const community = modules.filter((m) => m.source === 'community');
1784
- const custom = modules.filter((m) => m.source === 'custom');
1785
- const unknown = modules.filter((m) => m.source === 'unknown');
1786
-
1787
- const lines = [];
1788
- const formatGroup = (group, title) => {
1789
- if (group.length === 0) return;
1790
- lines.push(title);
1791
- for (const mod of group) {
1792
- const updateInfo = availableUpdates.find((u) => u.name === mod.name);
1793
- const versionDisplay = mod.version || 'unknown';
1794
- if (updateInfo) {
1795
- lines.push(` ${mod.name.padEnd(20)} ${versionDisplay} \u2192 ${updateInfo.latestVersion} \u2191`);
1796
- } else {
1797
- lines.push(` ${mod.name.padEnd(20)} ${versionDisplay} \u2713`);
1798
- }
1799
- }
1800
- };
1801
-
1802
- formatGroup(builtIn, 'Built-in Modules');
1803
- formatGroup(external, 'External Modules (Official)');
1804
- formatGroup(community, 'Community Modules');
1805
- formatGroup(custom, 'Custom Modules');
1806
- formatGroup(unknown, 'Other Modules');
1807
-
1808
- await prompts.note(lines.join('\n'), 'Module Versions');
1809
- }
1810
-
1811
- /**
1812
- * Prompt user to select which modules to update
1813
- * @param {Array} availableUpdates - Array of available updates
1814
- * @returns {Array} Selected module names to update
1815
- */
1816
- async promptUpdateSelection(availableUpdates) {
1817
- if (availableUpdates.length === 0) {
1818
- return [];
1819
- }
1820
-
1821
- await prompts.log.info('Available Updates');
1822
-
1823
- const choices = availableUpdates.map((update) => ({
1824
- name: `${update.name} (v${update.installedVersion} \u2192 v${update.latestVersion})`,
1825
- value: update.name,
1826
- checked: true, // Default to selecting all updates
1827
- }));
1828
-
1829
- // Add "Update All" and "Cancel" options
1830
- const action = await prompts.select({
1831
- message: 'How would you like to proceed?',
1832
- choices: [
1833
- { name: 'Update all available modules', value: 'all' },
1834
- { name: 'Select specific modules to update', value: 'select' },
1835
- { name: 'Skip updates for now', value: 'skip' },
1836
- ],
1837
- default: 'all',
1838
- });
1839
-
1840
- if (action === 'all') {
1841
- return availableUpdates.map((u) => u.name);
1842
- }
1843
-
1844
- if (action === 'skip') {
1845
- return [];
1846
- }
1847
-
1848
- // Allow specific selection
1849
- const selected = await prompts.multiselect({
1850
- message: 'Select modules to update (use arrow keys, space to toggle):',
1851
- choices: choices,
1852
- required: true,
1853
- });
1854
-
1855
- return selected || [];
1856
- }
1857
-
1858
- /**
1859
- * Display status of all installed modules
1860
- * @param {Object} statusData - Status data with modules, installation info, and available updates
1861
- */
1862
- async displayStatus(statusData) {
1863
- const { installation, modules, availableUpdates, bmadDir } = statusData;
1864
-
1865
- // Installation info
1866
- const infoLines = [
1867
- `Version: ${installation.version || 'unknown'}`,
1868
- `Location: ${bmadDir}`,
1869
- `Installed: ${new Date(installation.installDate).toLocaleDateString()}`,
1870
- `Last Updated: ${installation.lastUpdated ? new Date(installation.lastUpdated).toLocaleDateString() : 'unknown'}`,
1871
- ];
1872
-
1873
- await prompts.note(infoLines.join('\n'), 'BMAD Status');
1874
-
1875
- // Module versions
1876
- await this.displayModuleVersions(modules, availableUpdates);
1877
-
1878
- // Update summary
1879
- if (availableUpdates.length > 0) {
1880
- await prompts.log.warn(`${availableUpdates.length} update(s) available`);
1881
- await prompts.log.message('Run \'bmad install\' and select "Quick Update" to update');
1882
- } else {
1883
- await prompts.log.success('All modules are up to date');
1884
- }
1885
- }
1886
-
1887
- /**
1888
- * Display list of selected tools after IDE selection
1889
- * @param {Array} selectedIdes - Array of selected IDE values
1890
- * @param {Array} preferredIdes - Array of preferred IDE objects
1891
- * @param {Array} allTools - Array of all tool objects
1892
- */
1893
- async displaySelectedTools(selectedIdes, preferredIdes, allTools) {
1894
- if (selectedIdes.length === 0) return;
1895
-
1896
- const preferredValues = new Set(preferredIdes.map((ide) => ide.value));
1897
- const toolLines = selectedIdes.map((ideValue) => {
1898
- const tool = allTools.find((t) => t.value === ideValue);
1899
- const name = tool?.name || ideValue;
1900
- const marker = preferredValues.has(ideValue) ? ' \u2B50' : '';
1901
- return ` \u2022 ${name}${marker}`;
1902
- });
1903
- await prompts.log.message('Selected tools:\n' + toolLines.join('\n'));
1904
- }
1905
-
1906
- /**
1907
- * Return the set of module codes the registry marks as built-in (core, bmm).
1908
- * These ship with the installer binary and have no per-module channel.
1909
- */
1910
- async _bundledModuleCodes() {
1911
- const externalManager = new ExternalModuleManager();
1912
- try {
1913
- const modules = await externalManager.listAvailable();
1914
- return modules.filter((m) => m.builtIn).map((m) => m.code);
1915
- } catch {
1916
- // Registry unreachable — fall back to the known bundled codes.
1917
- return ['core', 'bmm'];
1918
- }
1919
- }
1920
-
1921
- /**
1922
- * Fast-path channel gate: confirm "all stable" or open the per-module picker.
1923
- *
1924
- * Skipped when:
1925
- * - running non-interactively (--yes)
1926
- * - the user already passed channel flags (--channel / --pin / --next), OR
1927
- * the installer was launched from a prerelease (which seeds
1928
- * channelOptions.global = 'next' upstream in promptInstall)
1929
- * - no externals/community modules are selected
1930
- *
1931
- * Mutates channelOptions.pins and channelOptions.nextSet to reflect picker choices.
1932
- */
1933
- async _interactiveChannelGate({ options, channelOptions, selectedModules }) {
1934
- // Figure out which selected modules actually get a channel (externals only).
1935
- // Bundled core/bmm and custom modules skip the picker.
1936
- const externalManager = new ExternalModuleManager();
1937
- const externals = await externalManager.listAvailable();
1938
- const externalByCode = new Map(externals.map((m) => [m.code, m]));
1939
-
1940
- const channelSelectable = selectedModules.filter((code) => {
1941
- const info = externalByCode.get(code);
1942
- return info && !info.builtIn;
1943
- });
1944
- if (channelSelectable.length === 0) return;
1945
-
1946
- // A registry pin marks the newest version this installer can install.
1947
- // Offering stable or next there leads to a failed install, so say what is
1948
- // pinned (headless installs included) and skip the picker for those modules.
1949
- await this._announcePinnedModules(channelSelectable, externalByCode, channelOptions);
1950
-
1951
- if (options.yes) return;
1952
- // If the user already declared their channel intent via flags, trust them
1953
- // and skip the gate.
1954
- const haveFlagIntent = channelOptions.global || channelOptions.nextSet.size > 0 || channelOptions.pins.size > 0;
1955
- if (haveFlagIntent) return;
1956
-
1957
- const choosable = channelSelectable.filter((code) => !externalByCode.get(code).pin);
1958
- if (choosable.length === 0) return;
1959
-
1960
- const fastPath = await prompts.confirm({
1961
- message: `Ready to install (all stable)? Pick "n" to customize channels or pin versions.`,
1962
- default: true,
1963
- });
1964
- if (fastPath) return; // stable for all, registry default applies
1965
-
1966
- // Customize path: per-module picker.
1967
- const { fetchStableTags, parseGitHubRepo } = require('./modules/channel-resolver');
1968
-
1969
- for (const code of choosable) {
1970
- const info = externalByCode.get(code);
1971
- const repoUrl = info.url;
1972
-
1973
- // Try to pre-resolve the top stable tag so we can surface it in the picker.
1974
- let stableLabel = 'stable (released version)';
1975
- try {
1976
- const parsed = repoUrl ? parseGitHubRepo(repoUrl) : null;
1977
- if (parsed) {
1978
- const tags = await fetchStableTags(parsed.owner, parsed.repo);
1979
- if (tags.length > 0) {
1980
- stableLabel = `stable ${tags[0].tag} (released version)`;
1981
- }
1982
- }
1983
- } catch {
1984
- // fall through with the generic label
1985
- }
1986
-
1987
- const choice = await prompts.select({
1988
- message: `${code}: choose a channel`,
1989
- choices: [
1990
- { name: stableLabel, value: 'stable' },
1991
- { name: 'pin (specific version)', value: 'pin' },
1992
- ],
1993
- default: 'stable',
1994
- });
1995
-
1996
- if (choice === 'pin') {
1997
- const pinValue = await prompts.text({
1998
- message: `Enter a version tag for '${code}' (e.g. v1.6.0):`,
1999
- validate: (value) => {
2000
- if (!value || !/^[\w.\-+/]+$/.test(String(value).trim())) {
2001
- return 'Must be a non-empty tag name (letters, digits, dots, hyphens).';
2002
- }
2003
- },
2004
- });
2005
- channelOptions.pins.set(code, String(pinValue).trim());
2006
- } else {
2007
- channelOptions.stableSet.add(code);
2008
- }
2009
- }
2010
- }
2011
-
2012
- /**
2013
- * Tell the user which selected modules sit on a registry pin and how to get a
2014
- * newer version. Skips a module whose version the user set with --pin/--next.
2015
- */
2016
- async _announcePinnedModules(codes, externalByCode, channelOptions) {
2017
- const { parseGitHubRepo } = require('./modules/channel-resolver');
2018
- for (const code of codes) {
2019
- const info = externalByCode.get(code);
2020
- if (!info || !info.pin || info.builtIn) continue;
2021
- if (channelOptions.pins.has(code) || channelOptions.nextSet.has(code)) continue;
2022
- const repo = info.url ? parseGitHubRepo(info.url) : null;
2023
- const where = repo ? ` Newer versions need the v7 installer: npx skills add ${repo.owner}/${repo.repo}` : '';
2024
- await prompts.log.info(`${code} is pinned to ${info.pin}.${where}`);
2025
- }
2026
- }
2027
-
2028
- /**
2029
- * Resolve channel decisions for an update over an existing install.
2030
- *
2031
- * For each selected external/community module:
2032
- * - Read the recorded channel from the existing manifest.
2033
- * - On `stable`: query tags; if a newer stable exists, classify the diff
2034
- * and prompt. Patch/minor default Y; major defaults N. `--yes` accepts
2035
- * defaults (patches/minors) but NOT majors — a major under --yes stays
2036
- * frozen unless the user also passes `--pin CODE=NEW_TAG`.
2037
- * - On `next`: no prompt (pull HEAD).
2038
- * - On `pinned`: no prompt (stays pinned).
2039
- * - No channel recorded and `version: null`: moves to stable, no prompt.
2040
- *
2041
- * Decisions that freeze the current version are applied by adding a pin to
2042
- * `channelOptions.pins` so downstream clone logic honors them.
2043
- */
2044
- async _resolveUpdateChannels({ bmadDir, selectedModules, channelOptions, yes }) {
2045
- const { Manifest } = require('./core/manifest');
2046
- const manifestObj = new Manifest();
2047
- const manifest = await manifestObj.read(bmadDir);
2048
- const existingByName = new Map();
2049
- for (const m of manifest?.modulesDetailed || []) {
2050
- if (m?.name) existingByName.set(m.name, m);
2051
- }
2052
- if (existingByName.size === 0) return;
2053
-
2054
- const externalManager = new ExternalModuleManager();
2055
- const externals = await externalManager.listAvailable();
2056
- const externalByCode = new Map(externals.map((m) => [m.code, m]));
2057
-
2058
- const { fetchStableTags, classifyUpgrade, releaseNotesUrl } = require('./modules/channel-resolver');
2059
- const { parseGitHubRepo } = require('./modules/channel-resolver');
2060
-
2061
- // Interactive-only: offer a one-time gate to review / switch channels for
2062
- // selected modules that are already installed. Default N so normal Modify
2063
- // flows (add/remove modules) aren't interrupted.
2064
- let reviewChannels = false;
2065
- if (!yes) {
2066
- const existingWithChannel = selectedModules.filter((code) => {
2067
- const prev = existingByName.get(code);
2068
- if (!prev) return false;
2069
- const info = externalByCode.get(code);
2070
- return info && !info.builtIn && !info.pin;
2071
- });
2072
- if (existingWithChannel.length > 0) {
2073
- reviewChannels = await prompts.confirm({
2074
- message: 'Review channel assignments (stable / pin) for your existing modules?',
2075
- default: false,
2076
- });
2077
- }
2078
- }
2079
-
2080
- for (const code of selectedModules) {
2081
- const prev = existingByName.get(code);
2082
- if (!prev) continue;
2083
-
2084
- const info = externalByCode.get(code);
2085
- if (!info) continue;
2086
- // Bundled modules (core/bmm) ship with the installer binary itself —
2087
- // their version is stapled to the CLI version, not a git tag. Skip
2088
- // tag-API lookups for them; the "upgrade" mechanism is `npx bmad@X install`.
2089
- if (info.builtIn) continue;
2090
- // A registry-pinned module stays on its pin; the channel logic below would
2091
- // move it to a version this installer cannot install. A version the user
2092
- // pinned earlier is kept.
2093
- if (info.pin) {
2094
- const decided = channelOptions.global || channelOptions.nextSet.has(code) || channelOptions.pins.has(code);
2095
- const keepsOwnPin = !decided && prev.channel === 'pinned' && prev.version && prev.version !== info.pin;
2096
- if (keepsOwnPin) {
2097
- channelOptions.pins.set(code, prev.version);
2098
- } else {
2099
- await this._announcePinnedModules([code], externalByCode, channelOptions);
2100
- }
2101
- continue;
2102
- }
2103
-
2104
- const repoUrl = info.url;
2105
- const parsed = repoUrl ? parseGitHubRepo(repoUrl) : null;
2106
-
2107
- // Legacy migration: manifest carries no channel and a null/empty
2108
- // version. The next channel is gone from the picker, so move it to stable.
2109
- const recordedChannel = prev.channel || null;
2110
- const needsMigration = !recordedChannel && (prev.version == null || prev.version === '');
2111
- if (needsMigration) {
2112
- if (yes) {
2113
- // Conservative headless default: stable.
2114
- continue;
2115
- }
2116
- channelOptions.stableSet.add(code);
2117
- continue;
2118
- }
2119
-
2120
- // Optional channel-switch offer. Fires only when the user opted in via
2121
- // the gate above. 'keep' falls through to the existing per-channel
2122
- // logic (which runs upgrade classification for stable). Any switch
2123
- // records the new intent into channelOptions and skips upgrade prompts.
2124
- if (reviewChannels && recordedChannel) {
2125
- const switchChoices = [
2126
- {
2127
- name: `Keep on '${recordedChannel}'${prev.version ? ` @ ${prev.version}` : ''}`,
2128
- value: 'keep',
2129
- },
2130
- ];
2131
- if (recordedChannel !== 'stable') {
2132
- switchChoices.push({ name: 'Switch to stable (released version)', value: 'stable' });
2133
- }
2134
- switchChoices.push({ name: 'Pin to a specific version tag', value: 'pin' });
2135
-
2136
- const choice = await prompts.select({
2137
- message: `${code} channel:`,
2138
- choices: switchChoices,
2139
- default: 'keep',
2140
- });
2141
-
2142
- if (choice === 'pin') {
2143
- const pinValue = await prompts.text({
2144
- message: `Enter a version tag for '${code}' (e.g. v1.6.0):`,
2145
- validate: (value) => {
2146
- if (!value || !/^[\w.\-+/]+$/.test(String(value).trim())) {
2147
- return 'Must be a non-empty tag name (letters, digits, dots, hyphens).';
2148
- }
2149
- },
2150
- });
2151
- channelOptions.pins.set(code, String(pinValue).trim());
2152
- continue;
2153
- }
2154
- if (choice === 'stable') {
2155
- // Switch to stable: install at the top stable tag without an
2156
- // upgrade-classification prompt (the user explicitly opted in).
2157
- channelOptions.stableSet.add(code);
2158
- // Also warm the tag cache here so the actual clone step doesn't
2159
- // need a second GitHub API call (can hit rate limits).
2160
- if (parsed) {
2161
- try {
2162
- await fetchStableTags(parsed.owner, parsed.repo);
2163
- } catch {
2164
- // best effort; clone step will surface any failure
2165
- }
2166
- }
2167
- continue;
2168
- }
2169
- // 'keep' → fall through with recordedChannel below.
2170
- }
2171
-
2172
- if (recordedChannel === 'pinned' || recordedChannel === 'next') {
2173
- // Respect any explicit channel intent the user already expressed via
2174
- // CLI flags (--channel / --all-* / --next=CODE / --pin CODE=TAG) or
2175
- // via the interactive review gate above. Only auto-re-assert the
2176
- // recorded channel when the user hasn't opted into anything else —
2177
- // otherwise --all-stable (or a review "switch to stable") would be
2178
- // silently clobbered by the prior channel.
2179
- const alreadyDecided = channelOptions.global || channelOptions.nextSet.has(code) || channelOptions.pins.has(code);
2180
- if (!alreadyDecided) {
2181
- if (recordedChannel === 'pinned' && prev.version) {
2182
- channelOptions.pins.set(code, prev.version);
2183
- } else if (recordedChannel === 'next') {
2184
- channelOptions.nextSet.add(code);
2185
- }
2186
- }
2187
- continue;
2188
- }
2189
-
2190
- // Stable channel: check for a newer released tag.
2191
- if (!parsed) continue;
2192
- // Respect explicit CLI intent (--pin / --next=CODE / --all-*) and any
2193
- // choice the user already made in the earlier review gate. Without this
2194
- // guard the upgrade classifier below would unconditionally call
2195
- // `channelOptions.pins.set(code, prev.version)` on decline/major-refuse/
2196
- // fetch-error, silently clobbering the user's override.
2197
- const alreadyDecided = channelOptions.global || channelOptions.nextSet.has(code) || channelOptions.pins.has(code);
2198
- if (alreadyDecided) continue;
2199
- let tags;
2200
- try {
2201
- tags = await fetchStableTags(parsed.owner, parsed.repo);
2202
- } catch (error) {
2203
- await prompts.log.warn(`Could not check for updates on ${code} (${error.message}). Leaving at ${prev.version}.`);
2204
- if (prev.version) channelOptions.pins.set(code, prev.version);
2205
- continue;
2206
- }
2207
- if (!tags || tags.length === 0) continue;
2208
- const topTag = tags[0].tag; // e.g. "v1.7.0"
2209
- const currentTag = prev.version || '';
2210
- const diffClass = classifyUpgrade(currentTag, topTag);
2211
-
2212
- if (diffClass === 'none') continue; // already at or above top tag
2213
-
2214
- const notes = releaseNotesUrl(repoUrl, topTag);
2215
- let accept;
2216
- if (diffClass === 'major') {
2217
- if (yes) {
2218
- // Major under --yes is refused by design.
2219
- await prompts.log.warn(
2220
- `${code} ${currentTag} → ${topTag} is a new major release; staying on ${currentTag}. ` +
2221
- `To accept, rerun with --pin ${code}=${topTag}.`,
2222
- );
2223
- channelOptions.pins.set(code, currentTag);
2224
- continue;
2225
- }
2226
- accept = await prompts.confirm({
2227
- message:
2228
- `${code} ${topTag} available — new major release (may change behavior).` +
2229
- (notes ? ` Release notes: ${notes}.` : '') +
2230
- ' Upgrade?',
2231
- default: false,
2232
- });
2233
- } else if (diffClass === 'minor') {
2234
- if (yes) {
2235
- accept = true;
2236
- } else {
2237
- accept = await prompts.confirm({
2238
- message: `${code} ${topTag} available (new features).` + (notes ? ` Release notes: ${notes}.` : '') + ' Upgrade?',
2239
- default: true,
2240
- });
2241
- }
2242
- } else {
2243
- // patch
2244
- if (yes) {
2245
- accept = true;
2246
- } else {
2247
- accept = await prompts.confirm({
2248
- message: `${code} ${topTag} available. Upgrade?`,
2249
- default: true,
2250
- });
2251
- }
2252
- }
2253
-
2254
- if (!accept && currentTag) {
2255
- // Freeze the current version by pinning it for this run.
2256
- channelOptions.pins.set(code, currentTag);
2257
- }
2258
- }
2259
- }
2260
- }
2261
-
2262
- module.exports = { UI };