bmad-plus 0.12.1 → 0.13.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 (176) hide show
  1. package/CHANGELOG.md +637 -580
  2. package/README.md +123 -120
  3. package/osint-agent-package/agents/osint-investigator.md +12 -0
  4. package/osint-agent-package/skills/bmad-osint-investigate/osint/SKILL.md +491 -482
  5. package/osint-agent-package/skills/bmad-osint-investigate/osint/assets/dossier-template.md +126 -126
  6. package/osint-agent-package/skills/bmad-osint-investigate/osint/assets/lawful-basis-record.md +48 -48
  7. package/osint-agent-package/skills/bmad-osint-investigate/osint/references/content-extraction.md +100 -100
  8. package/osint-agent-package/skills/bmad-osint-investigate/osint/references/gdpr-osint.md +48 -48
  9. package/osint-agent-package/skills/bmad-osint-investigate/osint/references/platforms.md +130 -130
  10. package/osint-agent-package/skills/bmad-osint-investigate/osint/references/psychoprofile.md +69 -69
  11. package/osint-agent-package/skills/bmad-osint-investigate/osint/references/tools.md +281 -281
  12. package/osint-agent-package/skills/bmad-osint-investigate/osint/scripts/mcp-client.py +136 -136
  13. package/package.json +106 -91
  14. package/readme-international/README.de.md +625 -594
  15. package/readme-international/README.es.md +642 -611
  16. package/readme-international/README.fr.md +640 -609
  17. package/src/bmad-plus/agents/agent-orchestrator/SKILL.md +2 -0
  18. package/src/bmad-plus/agents/agent-shadow/SKILL.md +18 -0
  19. package/src/bmad-plus/data/role-triggers.yaml +52 -0
  20. package/src/bmad-plus/module.yaml +333 -283
  21. package/src/bmad-plus/packs/pack-animated/animated-website-agent.md +325 -325
  22. package/src/bmad-plus/packs/pack-animated/templates/animated-website-workflow.md +55 -55
  23. package/src/bmad-plus/packs/pack-backup/backup-agent.md +71 -71
  24. package/src/bmad-plus/packs/pack-backup/templates/backup-workflow.md +51 -51
  25. package/src/bmad-plus/packs/pack-dev-studio/README.md +162 -162
  26. package/src/bmad-plus/packs/pack-dev-studio/categories/analysis/analyst-agent.md +73 -73
  27. package/src/bmad-plus/packs/pack-dev-studio/categories/analysis/document-project.md +61 -61
  28. package/src/bmad-plus/packs/pack-dev-studio/categories/analysis/domain-research.md +95 -95
  29. package/src/bmad-plus/packs/pack-dev-studio/categories/analysis/market-research.md +95 -95
  30. package/src/bmad-plus/packs/pack-dev-studio/categories/analysis/prfaq.md +134 -134
  31. package/src/bmad-plus/packs/pack-dev-studio/categories/analysis/product-brief.md +80 -80
  32. package/src/bmad-plus/packs/pack-dev-studio/categories/analysis/tech-writer-agent.md +73 -73
  33. package/src/bmad-plus/packs/pack-dev-studio/categories/analysis/technical-research.md +95 -95
  34. package/src/bmad-plus/packs/pack-dev-studio/categories/architecture/architect-agent.md +73 -73
  35. package/src/bmad-plus/packs/pack-dev-studio/categories/architecture/create-architecture.md +73 -73
  36. package/src/bmad-plus/packs/pack-dev-studio/categories/architecture/create-epics-stories.md +92 -92
  37. package/src/bmad-plus/packs/pack-dev-studio/categories/architecture/generate-project-context.md +80 -80
  38. package/src/bmad-plus/packs/pack-dev-studio/categories/architecture/implementation-readiness.md +90 -90
  39. package/src/bmad-plus/packs/pack-dev-studio/categories/architecture/steps/step-01-init.md +153 -153
  40. package/src/bmad-plus/packs/pack-dev-studio/categories/architecture/steps/step-01b-continue.md +173 -173
  41. package/src/bmad-plus/packs/pack-dev-studio/categories/architecture/steps/step-02-context.md +224 -224
  42. package/src/bmad-plus/packs/pack-dev-studio/categories/architecture/steps/step-03-starter.md +329 -329
  43. package/src/bmad-plus/packs/pack-dev-studio/categories/architecture/steps/step-04-decisions.md +318 -318
  44. package/src/bmad-plus/packs/pack-dev-studio/categories/architecture/steps/step-05-patterns.md +359 -359
  45. package/src/bmad-plus/packs/pack-dev-studio/categories/architecture/steps/step-06-structure.md +379 -379
  46. package/src/bmad-plus/packs/pack-dev-studio/categories/architecture/steps/step-07-validation.md +361 -361
  47. package/src/bmad-plus/packs/pack-dev-studio/categories/architecture/steps/step-08-complete.md +81 -81
  48. package/src/bmad-plus/packs/pack-dev-studio/categories/implementation/checkpoint-preview.md +67 -67
  49. package/src/bmad-plus/packs/pack-dev-studio/categories/implementation/code-review-steps/step-01-gather-context.md +85 -85
  50. package/src/bmad-plus/packs/pack-dev-studio/categories/implementation/code-review-steps/step-02-review.md +35 -35
  51. package/src/bmad-plus/packs/pack-dev-studio/categories/implementation/code-review-steps/step-03-triage.md +49 -49
  52. package/src/bmad-plus/packs/pack-dev-studio/categories/implementation/code-review-steps/step-04-present.md +131 -131
  53. package/src/bmad-plus/packs/pack-dev-studio/categories/implementation/code-review.md +89 -89
  54. package/src/bmad-plus/packs/pack-dev-studio/categories/implementation/correct-course.md +300 -300
  55. package/src/bmad-plus/packs/pack-dev-studio/categories/implementation/create-story.md +428 -428
  56. package/src/bmad-plus/packs/pack-dev-studio/categories/implementation/dev-agent.md +73 -73
  57. package/src/bmad-plus/packs/pack-dev-studio/categories/implementation/dev-story-checklist.md +80 -80
  58. package/src/bmad-plus/packs/pack-dev-studio/categories/implementation/dev-story.md +484 -484
  59. package/src/bmad-plus/packs/pack-dev-studio/categories/implementation/investigate.md +193 -193
  60. package/src/bmad-plus/packs/pack-dev-studio/categories/implementation/qa-e2e-tests.md +175 -175
  61. package/src/bmad-plus/packs/pack-dev-studio/categories/implementation/quick-dev.md +110 -110
  62. package/src/bmad-plus/packs/pack-dev-studio/categories/implementation/retrospective.md +1511 -1511
  63. package/src/bmad-plus/packs/pack-dev-studio/categories/implementation/sprint-planning.md +298 -298
  64. package/src/bmad-plus/packs/pack-dev-studio/categories/implementation/sprint-status.md +296 -296
  65. package/src/bmad-plus/packs/pack-dev-studio/categories/planning/create-prd.md +29 -29
  66. package/src/bmad-plus/packs/pack-dev-studio/categories/planning/create-ux-design.md +74 -74
  67. package/src/bmad-plus/packs/pack-dev-studio/categories/planning/edit-prd.md +29 -29
  68. package/src/bmad-plus/packs/pack-dev-studio/categories/planning/pm-agent.md +73 -73
  69. package/src/bmad-plus/packs/pack-dev-studio/categories/planning/prd.md +89 -89
  70. package/src/bmad-plus/packs/pack-dev-studio/categories/planning/ux-designer-agent.md +73 -73
  71. package/src/bmad-plus/packs/pack-dev-studio/categories/planning/validate-prd.md +29 -29
  72. package/src/bmad-plus/packs/pack-dev-studio/categories/utilities/advanced-elicitation.md +141 -141
  73. package/src/bmad-plus/packs/pack-dev-studio/categories/utilities/adversarial-review.md +37 -37
  74. package/src/bmad-plus/packs/pack-dev-studio/categories/utilities/bmad-help.md +75 -75
  75. package/src/bmad-plus/packs/pack-dev-studio/categories/utilities/brainstorming.md +6 -6
  76. package/src/bmad-plus/packs/pack-dev-studio/categories/utilities/customize.md +110 -110
  77. package/src/bmad-plus/packs/pack-dev-studio/categories/utilities/distillator.md +176 -176
  78. package/src/bmad-plus/packs/pack-dev-studio/categories/utilities/edge-case-hunter.md +67 -67
  79. package/src/bmad-plus/packs/pack-dev-studio/categories/utilities/editorial-review-prose.md +86 -86
  80. package/src/bmad-plus/packs/pack-dev-studio/categories/utilities/editorial-review-structure.md +179 -179
  81. package/src/bmad-plus/packs/pack-dev-studio/categories/utilities/index-docs.md +66 -66
  82. package/src/bmad-plus/packs/pack-dev-studio/categories/utilities/party-mode.md +127 -127
  83. package/src/bmad-plus/packs/pack-dev-studio/categories/utilities/shard-doc.md +105 -105
  84. package/src/bmad-plus/packs/pack-dev-studio/dev-studio-orchestrator.md +120 -120
  85. package/src/bmad-plus/packs/pack-dev-studio/shared/architecture-decision-template.md +12 -12
  86. package/src/bmad-plus/packs/pack-dev-studio/shared/bwml-spec.md +328 -328
  87. package/src/bmad-plus/packs/pack-dev-studio/shared/module-help.csv +32 -32
  88. package/src/bmad-plus/packs/pack-dev-studio/upstream-sync.yaml +81 -81
  89. package/src/bmad-plus/packs/pack-seo/SKILL.md +171 -171
  90. package/src/bmad-plus/packs/pack-seo/checklist.md +140 -140
  91. package/src/bmad-plus/packs/pack-seo/pagespeed-playbook.md +320 -320
  92. package/src/bmad-plus/packs/pack-seo/ref/audit-schema.json +187 -187
  93. package/src/bmad-plus/packs/pack-seo/ref/cwv-thresholds.md +87 -87
  94. package/src/bmad-plus/packs/pack-seo/ref/eeat-criteria.md +123 -123
  95. package/src/bmad-plus/packs/pack-seo/ref/geo-signals.md +167 -167
  96. package/src/bmad-plus/packs/pack-seo/ref/hreflang-rules.md +153 -153
  97. package/src/bmad-plus/packs/pack-seo/ref/quality-gates.md +133 -133
  98. package/src/bmad-plus/packs/pack-seo/ref/schema-catalog.md +91 -91
  99. package/src/bmad-plus/packs/pack-seo/ref/schema-templates.json +356 -356
  100. package/src/bmad-plus/packs/pack-seo/requirements.txt +17 -0
  101. package/src/bmad-plus/packs/pack-seo/scripts/seo_apis.py +456 -0
  102. package/src/bmad-plus/packs/pack-seo/scripts/seo_crawl.py +359 -0
  103. package/src/bmad-plus/packs/pack-seo/scripts/seo_fetch.py +303 -0
  104. package/src/bmad-plus/packs/pack-seo/scripts/seo_parse.py +255 -0
  105. package/src/bmad-plus/packs/pack-seo/scripts/seo_report.py +409 -0
  106. package/src/bmad-plus/packs/pack-seo/scripts/seo_screenshot.py +202 -0
  107. package/src/bmad-plus/packs/pack-seo/seo-chief.md +294 -294
  108. package/src/bmad-plus/packs/pack-seo/seo-judge.md +241 -241
  109. package/src/bmad-plus/packs/pack-seo/seo-scout.md +171 -171
  110. package/src/bmad-plus/packs/pack-seo/templates/seo-audit-workflow.md +241 -241
  111. package/src/bmad-plus/packs/pack-shield/README.md +6 -6
  112. package/src/bmad-plus/packs/pack-shield/SKILL.md +2 -2
  113. package/src/bmad-plus/packs/pack-shield/categories/accessibility-esg/csrd-agent.md +11 -11
  114. package/src/bmad-plus/packs/pack-shield/categories/accessibility-esg/section508-agent.md +11 -11
  115. package/src/bmad-plus/packs/pack-shield/categories/accessibility-esg/wcag-agent.md +11 -11
  116. package/src/bmad-plus/packs/pack-shield/categories/ai-governance/eu-ai-act-agent.md +11 -11
  117. package/src/bmad-plus/packs/pack-shield/categories/ai-governance/iso42001-agent.md +11 -11
  118. package/src/bmad-plus/packs/pack-shield/categories/ai-governance/nist-ai-rmf-agent.md +11 -11
  119. package/src/bmad-plus/packs/pack-shield/categories/cybersecurity/cis-controls-agent.md +11 -11
  120. package/src/bmad-plus/packs/pack-shield/categories/cybersecurity/ism-agent.md +11 -11
  121. package/src/bmad-plus/packs/pack-shield/categories/cybersecurity/iso27001-agent.md +11 -11
  122. package/src/bmad-plus/packs/pack-shield/categories/cybersecurity/nis2-agent.md +11 -11
  123. package/src/bmad-plus/packs/pack-shield/categories/cybersecurity/nist-800-53-agent.md +11 -11
  124. package/src/bmad-plus/packs/pack-shield/categories/cybersecurity/nist-csf-agent.md +11 -11
  125. package/src/bmad-plus/packs/pack-shield/categories/defense-export/cmmc-agent.md +11 -11
  126. package/src/bmad-plus/packs/pack-shield/categories/defense-export/ear-agent.md +11 -11
  127. package/src/bmad-plus/packs/pack-shield/categories/defense-export/itar-agent.md +11 -11
  128. package/src/bmad-plus/packs/pack-shield/categories/defense-export/tsa-agent.md +11 -11
  129. package/src/bmad-plus/packs/pack-shield/categories/industry-compliance/dora-agent.md +11 -11
  130. package/src/bmad-plus/packs/pack-shield/categories/industry-compliance/fedramp-agent.md +11 -11
  131. package/src/bmad-plus/packs/pack-shield/categories/industry-compliance/hipaa-agent.md +11 -11
  132. package/src/bmad-plus/packs/pack-shield/categories/industry-compliance/pci-dss-agent.md +11 -11
  133. package/src/bmad-plus/packs/pack-shield/categories/industry-compliance/soc2-agent.md +11 -11
  134. package/src/bmad-plus/packs/pack-shield/categories/industry-compliance/swift-csp-agent.md +11 -11
  135. package/src/bmad-plus/packs/pack-shield/shield-orchestrator.md +1 -1
  136. package/src/bmad-plus/skills/bmad-plus-autopilot/SKILL.md +1 -1
  137. package/tools/bmad-plus-npx.js +4 -2
  138. package/tools/build/adapters.config.js +60 -51
  139. package/tools/build/check-counts.js +626 -0
  140. package/tools/build/check-install-contract.js +298 -0
  141. package/tools/build/generate-adapters.js +252 -56
  142. package/tools/build/generate.js +187 -10
  143. package/tools/build/generated-adapters/.codex/AGENTS.md +20 -7
  144. package/tools/build/generated-adapters/.cursor/rules/bmad-plus.mdc +20 -7
  145. package/tools/build/generated-adapters/.opencode/AGENTS.md +20 -7
  146. package/tools/build/generated-adapters/AGENTS.md +20 -7
  147. package/tools/build/generated-adapters/CLAUDE.md +20 -7
  148. package/tools/build/generated-adapters/CONVENTIONS.md +20 -7
  149. package/tools/build/generated-adapters/GEMINI.md +20 -7
  150. package/tools/build/module.template.yaml +82 -0
  151. package/tools/cli/bmad-plus-cli.js +16 -1
  152. package/tools/cli/commands/autoconfig.js +470 -470
  153. package/tools/cli/commands/doctor.js +205 -233
  154. package/tools/cli/commands/install.js +543 -501
  155. package/tools/cli/commands/memory-journal-cmd.js +311 -311
  156. package/tools/cli/commands/memory.js +195 -195
  157. package/tools/cli/commands/scan.js +348 -348
  158. package/tools/cli/commands/uninstall.js +209 -101
  159. package/tools/cli/commands/update-check.js +31 -0
  160. package/tools/cli/commands/update-policy.js +39 -0
  161. package/tools/cli/commands/update.js +123 -134
  162. package/tools/cli/i18n.js +905 -845
  163. package/tools/cli/lib/README-memory-journal.md +125 -125
  164. package/tools/cli/lib/ide-config.js +10 -259
  165. package/tools/cli/lib/install-manifest.js +17 -0
  166. package/tools/cli/lib/installed-adapters.js +89 -0
  167. package/tools/cli/lib/npm-runner.js +177 -0
  168. package/tools/cli/lib/pack-copy.js +62 -66
  169. package/tools/cli/lib/packs.js +437 -3
  170. package/tools/cli/lib/python-provision.js +508 -508
  171. package/tools/cli/lib/stack-detect.js +102 -102
  172. package/tools/cli/lib/update-check.js +153 -0
  173. package/tools/cli/lib/update-dispatch.js +182 -0
  174. package/tools/cli/lib/update-policy.js +90 -0
  175. package/tools/cli/lib/update-transaction.js +334 -0
  176. package/tools/cli/lib/validate.js +50 -50
@@ -1,501 +1,543 @@
1
- /**
2
- * BMAD+ Install Command
3
- * Installs agents, skills, and IDE configs into the current project
4
- * Supports 10 languages: EN, FR, ES, DE, PT-BR, RU, ZH, HE, JA, IT
5
- *
6
- * Author: Laurent Rochetta
7
- */
8
-
9
- const path = require('node:path');
10
- const fs = require('node:fs');
11
- const fsExtra = require('fs-extra');
12
- const clack = require('@clack/prompts');
13
- const pc = require('picocolors');
14
- const { t, getLanguageOptions, getCommLanguageOptions } = require('../i18n');
15
- const { PACKS } = require('../lib/packs');
16
- const { copyPackFiles } = require('../lib/pack-copy');
17
- const { initMemory } = require('../lib/memory-init');
18
- const { generateIDEConfig, IDE_CONFIGS } = require('../lib/ide-config');
19
- const { validateUserName } = require('../lib/validate');
20
- const { provisionPack } = require('../lib/python-provision');
21
-
22
- // Packs whose runtime includes Python (registry.yaml: runtime includes "python").
23
- // Provisioned only when the user opts in with --provision-python, so the default
24
- // install (and the test suite) never spawns Python. Kills SEO "broken on arrival".
25
- const PYTHON_PACKS = {
26
- seo: {
27
- requirements: ['oveanet-pack', 'seo-audit-360', 'requirements.txt'],
28
- verifyModules: ['requests', 'bs4', 'defusedxml', 'lxml'],
29
- },
30
- memory: {
31
- requirements: ['mcp-server', 'requirements.txt'],
32
- verifyModules: ['chromadb'],
33
- },
34
- };
35
-
36
- // Pack definitions are imported from the shared module: require('../lib/packs').PACKS
37
-
38
- module.exports = {
39
- command: 'install',
40
- description: 'Install BMAD+ agents and skills into your project',
41
- options: [
42
- ['-d, --directory <path>', 'Installation directory (default: current directory)'],
43
- ['-p, --packs <packs>', 'Comma-separated pack IDs: core,osint,all (default: interactive)'],
44
- ['-y, --yes', 'Accept all defaults, skip prompts'],
45
- ['-l, --lang <code>', 'Language code: en, fr, es, de, pt-br, ru, zh, he, ja, it (overrides auto-detection)'],
46
- ['--tools <tools>', 'Comma-separated IDE IDs (default: auto-detect)'],
47
- ['--provision-python', 'Provision an isolated Python env for packs that need one (seo, memory)'],
48
- ],
49
- action: async (options) => {
50
- const projectDir = path.resolve(options.directory || process.cwd());
51
- const bmadSrc = path.join(__dirname, '..', '..', '..', 'src', 'bmad-plus');
52
-
53
- // ── Step 0: Language Selection ──
54
- const pkgJson = require('../../../package.json');
55
- clack.intro(pc.bgCyan(pc.black(` BMAD+ Installer v${pkgJson.version} `)));
56
- clack.log.info(pc.dim('✨ Created by Laurent Rochetta — github.com/lrochetta/BMAD-PLUS'));
57
-
58
- let lang = options.lang || 'en';
59
- if (!options.yes && !options.lang) {
60
- const langChoice = await clack.select({
61
- message: '🌐 Select your language / Choisissez votre langue / 选择语言',
62
- options: getLanguageOptions(),
63
- });
64
-
65
- if (clack.isCancel(langChoice)) {
66
- clack.cancel('Installation cancelled.');
67
- throw new Error('Installation cancelled.');
68
- }
69
- lang = langChoice;
70
- }
71
-
72
- const i = t(lang); // Get translations for selected language
73
-
74
- // Verify source exists
75
- if (!fs.existsSync(bmadSrc)) {
76
- clack.log.error(`${i.source_not_found}: ${bmadSrc}`);
77
- clack.outro(pc.red(i.failed));
78
- throw new Error(`Source not found: ${bmadSrc}`);
79
- }
80
-
81
- clack.log.info(`${i.installing_to}: ${pc.cyan(projectDir)}`);
82
-
83
- // ── Step 1: Pack Selection ──
84
- let selectedPacks = ['core']; // Core always included
85
-
86
- if (options.packs) {
87
- const requested = options.packs.split(',').map(p => p.trim());
88
- if (requested.includes('all')) {
89
- selectedPacks = Object.keys(PACKS).filter(k => !PACKS[k].disabled);
90
- } else {
91
- selectedPacks = [...new Set(['core', ...requested.filter(p => PACKS[p] && !PACKS[p].disabled)])];
92
- }
93
- } else if (!options.yes) {
94
- const packChoice = await clack.multiselect({
95
- message: i.select_packs,
96
- options: Object.entries(PACKS)
97
- .filter(([, p]) => !p.required)
98
- .map(([key, pack]) => ({
99
- value: key,
100
- label: `${pack.icon} ${pack.name}`,
101
- hint: pack.disabled ? i.soon : (pack.desc || pack.description || ''),
102
- disabled: pack.disabled,
103
- })),
104
- required: false,
105
- });
106
-
107
- if (clack.isCancel(packChoice)) {
108
- clack.cancel(i.cancelled);
109
- throw new Error(i.cancelled);
110
- }
111
-
112
- selectedPacks = [...new Set(['core', ...packChoice])];
113
- }
114
-
115
- clack.log.success(`${i.selected_packs}: ${selectedPacks.map(p => `${PACKS[p].icon} ${PACKS[p].name}`).join(', ')}`);
116
-
117
- // ── Step 2: IDE Detection ──
118
- let detectedIDEs = [];
119
-
120
- if (options.tools) {
121
- if (options.tools === 'none' || options.tools === 'skip') {
122
- detectedIDEs = [];
123
- } else {
124
- detectedIDEs = options.tools.split(',').map(t => t.trim()).filter(t => IDE_CONFIGS[t]);
125
- }
126
- } else {
127
- // Auto-detect
128
- for (const [id, ide] of Object.entries(IDE_CONFIGS)) {
129
- for (const marker of ide.detect) {
130
- if (fs.existsSync(path.join(projectDir, marker))) {
131
- detectedIDEs.push(id);
132
- break;
133
- }
134
- }
135
- }
136
-
137
- // If nothing detected, ask
138
- if (detectedIDEs.length === 0 && !options.yes) {
139
- const ideChoice = await clack.multiselect({
140
- message: i.select_ide,
141
- options: Object.entries(IDE_CONFIGS).map(([key, ide]) => ({
142
- value: key,
143
- label: ide.name,
144
- })),
145
- required: false,
146
- });
147
-
148
- if (!clack.isCancel(ideChoice)) {
149
- detectedIDEs = ideChoice;
150
- }
151
- }
152
-
153
- // Default to all if --yes
154
- if (detectedIDEs.length === 0 && options.yes) {
155
- detectedIDEs = Object.keys(IDE_CONFIGS);
156
- }
157
- }
158
-
159
- if (detectedIDEs.length > 0) {
160
- clack.log.info(`${i.detected_ides}: ${detectedIDEs.map(id => IDE_CONFIGS[id].name).join(', ')}`);
161
- } else if (options.tools === 'none' || options.tools === 'skip') {
162
- clack.log.info(pc.dim('⏭️ IDE config skipped (--tools none) — existing configs preserved'));
163
- }
164
-
165
- // ── Step 3: User Config ──
166
- let userName = process.env.USER || process.env.USERNAME || 'Developer';
167
- let commLang = 'French';
168
-
169
- if (!options.yes) {
170
- const userConfig = await clack.group({
171
- userName: () => clack.text({
172
- message: i.enter_name,
173
- placeholder: userName,
174
- defaultValue: userName,
175
- }),
176
- commLang: () => clack.select({
177
- message: i.comm_language,
178
- options: getCommLanguageOptions(),
179
- }),
180
- execMode: () => clack.select({
181
- message: i.exec_mode,
182
- options: [
183
- { value: 'manual', label: i.exec_manual },
184
- { value: 'autopilot', label: i.exec_autopilot },
185
- { value: 'hybrid', label: i.exec_hybrid },
186
- ],
187
- }),
188
- });
189
-
190
- if (clack.isCancel(userConfig)) {
191
- clack.cancel(i.cancelled);
192
- throw new Error(i.cancelled);
193
- }
194
-
195
- // Validate user-provided name
196
- const rawName = userConfig.userName;
197
- const fb = process.env.USER || process.env.USERNAME || 'Developer';
198
- const { name: validatedName, warnings } = validateUserName(rawName, fb);
199
- for (const w of warnings) clack.log.warn(w);
200
- userName = validatedName;
201
- commLang = userConfig.commLang;
202
- }
203
-
204
- // ── Step 4: Install Files ──
205
- const spinner = clack.spinner();
206
- spinner.start(i.installing_files);
207
-
208
- const targetAgentsDir = path.join(projectDir, '.agents', 'skills');
209
- const targetDataDir = path.join(projectDir, '.agents', 'data');
210
- const targetBmadDir = path.join(projectDir, '_bmad');
211
-
212
- // Create directories
213
- fsExtra.ensureDirSync(targetAgentsDir);
214
- fsExtra.ensureDirSync(targetDataDir);
215
- fsExtra.ensureDirSync(targetBmadDir);
216
-
217
- let copiedAgents = 0;
218
- let copiedSkills = 0;
219
- let copiedFiles = 0;
220
-
221
- const projectRoot = path.join(bmadSrc, '..', '..');
222
-
223
- for (const packId of selectedPacks) {
224
- const pack = PACKS[packId];
225
- if (!pack || pack.disabled) continue;
226
-
227
- const result = copyPackFiles({
228
- bmadSrc,
229
- targetAgentsDir,
230
- targetDataDir,
231
- projectRoot,
232
- pack,
233
- });
234
- copiedAgents += result.copiedAgents;
235
- copiedSkills += result.copiedSkills;
236
- copiedFiles += result.copiedFiles;
237
-
238
- // Memory pack: initialize brain with existing brain detection.
239
- // Non-fatal: a read-only or missing home dir (containers, CI) must not
240
- // abort the install mid-flight and leave a manifest-less partial tree.
241
- if (packId === 'memory' && pack.packDir) {
242
- try {
243
- initMemory({ projectDir, bmadSrc, userName, commLang, selectedPacks });
244
- } catch (err) {
245
- clack.log.warn(`Memory/brain initialization failed (non-fatal, install continues): ${err.message}`);
246
- }
247
- }
248
- }
249
-
250
- // ── Python provisioning (opt-in) for packs whose runtime needs Python ──
251
- // Off by default so `install` never spawns Python unless asked. Closes the
252
- // "SEO pack ships prompts that call scripts never installed" gap (PROD-02).
253
- if (options.provisionPython) {
254
- const pythonPacks = selectedPacks.filter((p) => PYTHON_PACKS[p]);
255
- for (const packId of pythonPacks) {
256
- const cfg = PYTHON_PACKS[packId];
257
- const requirementsPath = path.join(projectRoot, ...cfg.requirements);
258
- if (!fs.existsSync(requirementsPath)) {
259
- clack.log.warn(`Python provisioning skipped for ${packId}: ${requirementsPath} not found.`);
260
- continue;
261
- }
262
- const pySpinner = clack.spinner();
263
- pySpinner.start(`Provisioning Python runtime for ${PACKS[packId].name}…`);
264
- const res = provisionPack({
265
- envDir: path.join(projectDir, '.bmad', 'venv', packId),
266
- requirementsPath,
267
- verifyModules: cfg.verifyModules,
268
- });
269
- pySpinner.stop(
270
- res.ok
271
- ? `${PACKS[packId].name}: Python runtime ready (${res.tool}).`
272
- : `${PACKS[packId].name}: Python not provisioned — ${res.messages[res.messages.length - 1] || 'see guidance'}`
273
- );
274
- if (!res.ok) {
275
- clack.log.warn(`Run \`${PACKS[packId].name}\` Python tools after installing Python ≥3.11; the pack's prompts still work, only the local scripts need the runtime.`);
276
- }
277
- }
278
- }
279
-
280
- // Copy module config
281
- const moduleYaml = path.join(bmadSrc, 'module.yaml');
282
- if (fs.existsSync(moduleYaml)) {
283
- fsExtra.copySync(moduleYaml, path.join(targetBmadDir, 'module.yaml'));
284
- copiedFiles++;
285
- }
286
-
287
- const helpCsv = path.join(bmadSrc, 'module-help.csv');
288
- if (fs.existsSync(helpCsv)) {
289
- fsExtra.copySync(helpCsv, path.join(targetBmadDir, 'module-help.csv'));
290
- copiedFiles++;
291
- }
292
-
293
- spinner.stop(i.installed_summary(copiedAgents, copiedSkills, copiedFiles));
294
-
295
- // ── Step 5: Generate IDE Configs ──
296
- if (detectedIDEs.length > 0) {
297
- const ideSpinner = clack.spinner();
298
- ideSpinner.start(i.configuring_ides);
299
-
300
- const configContent = generateIDEConfig(userName, commLang, selectedPacks);
301
- // Marker present in every BMAD+-generated IDE config (see lib/ide-config.js).
302
- const BMAD_MARKER = 'BMAD+ — AI Agent Configuration';
303
-
304
- for (const ideId of detectedIDEs) {
305
- const ide = IDE_CONFIGS[ideId];
306
- if (!ide) continue;
307
-
308
- const configPath = path.join(projectDir, ide.configFile);
309
-
310
- // NODE-02: never clobber a hand-authored config without protecting it.
311
- if (fs.existsSync(configPath)) {
312
- const existing = fs.readFileSync(configPath, 'utf8');
313
- if (!existing.includes(BMAD_MARKER)) {
314
- if (!options.yes) {
315
- // Interactive: keep the user's file untouched.
316
- clack.log.warn(`⚠️ ${ide.configFile} already exists and was not created by BMAD+ — kept your file (skipped). Re-run with --yes to back it up and overwrite.`);
317
- continue;
318
- }
319
- // Non-interactive: back up before overwriting, never destroy data.
320
- let backupPath = `${configPath}.bak`;
321
- if (fs.existsSync(backupPath)) backupPath = `${configPath}.${Date.now()}.bak`;
322
- fs.copyFileSync(configPath, backupPath);
323
- clack.log.warn(`⚠️ Backed up existing ${ide.configFile} → ${path.basename(backupPath)}`);
324
- }
325
- }
326
-
327
- fs.writeFileSync(configPath, configContent, 'utf8');
328
- }
329
-
330
- ideSpinner.stop(i.ide_configured(detectedIDEs.length));
331
- }
332
-
333
- // ── Step 6: Create config.yaml ──
334
- const configYaml = generateConfigYaml(userName, commLang, projectDir);
335
- const configPath = path.join(targetBmadDir, 'config.yaml');
336
- fs.writeFileSync(configPath, configYaml, 'utf8');
337
-
338
- // ── Step 7: Create output directories ──
339
- const outputDir = path.join(projectDir, '_bmad-output');
340
- fsExtra.ensureDirSync(path.join(outputDir, 'discovery'));
341
- fsExtra.ensureDirSync(path.join(outputDir, 'build'));
342
- fsExtra.ensureDirSync(path.join(projectDir, 'docs'));
343
-
344
- // ── Step 8: Write install manifest ──
345
- const pkgVersion = require('../../../package.json').version;
346
- const manifest = {
347
- version: pkgVersion,
348
- uiLanguage: lang,
349
- installed: new Date().toISOString(),
350
- packs: selectedPacks,
351
- ides: detectedIDEs,
352
- user: userName,
353
- language: commLang,
354
- };
355
- fs.writeFileSync(
356
- path.join(targetBmadDir, '.bmad-plus-install.json'),
357
- JSON.stringify(manifest, null, 2),
358
- 'utf8'
359
- );
360
-
361
- // ── Summary — Contextual Getting Started ──
362
- const agentGuide = [
363
- i.guide_who,
364
- '',
365
- ` ${i.guide_idea.padEnd(28)} → "Atlas, [...]"`,
366
- ` ${i.guide_prd.padEnd(28)} → "Atlas, create PRD"`,
367
- ` ${i.guide_arch.padEnd(28)} → "Forge, propose architecture"`,
368
- ` ${i.guide_code.padEnd(28)} → "Forge, implement story [X]"`,
369
- ` ${i.guide_test.padEnd(28)} → "Sentinel, review module [X]"`,
370
- ` ${i.guide_sprint.padEnd(28)} → "Nexus, create epics"`,
371
- ` ${i.guide_auto.padEnd(28)} → "autopilot"`,
372
- ];
373
-
374
- if (selectedPacks.includes('osint')) {
375
- agentGuide.push(` ${i.guide_osint.padEnd(28)} → "Shadow, investigate [name]"`);
376
- }
377
-
378
- if (selectedPacks.includes('maker')) {
379
- agentGuide.push(` ${i.guide_maker.padEnd(28)} → "Maker, create agent [desc]"`);
380
- }
381
-
382
- if (selectedPacks.includes('seo')) {
383
- agentGuide.push(` ${i.guide_seo.padEnd(28)} → "/seo audit <url>"`);
384
- }
385
-
386
- if (selectedPacks.includes('backup')) {
387
- agentGuide.push(` ${i.guide_backup.padEnd(28)} → "/backup create"`);
388
- }
389
-
390
- if (selectedPacks.includes('animated')) {
391
- agentGuide.push(` ${i.guide_animated.padEnd(28)} → "/animated build <video>"`);
392
- }
393
-
394
- if (selectedPacks.includes('shield')) {
395
- agentGuide.push(` ${(i.guide_shield || '🛡️ GRC Compliance').padEnd(28)} → "Shield, audit my SaaS for GDPR"`);
396
- }
397
-
398
- if (selectedPacks.includes('memory')) {
399
- agentGuide.push(` ${(i.guide_memory || '🧠 Memory Brain').padEnd(28)} → "Zecher, scan projects in [path]"`);
400
- }
401
-
402
- if (selectedPacks.includes('dev-studio')) {
403
- agentGuide.push(` ${(i.guide_dev_studio || '🏗️ Dev Studio').padEnd(28)} → "Miriam, brainstorm my app idea"`);
404
- }
405
-
406
- agentGuide.push(
407
- '',
408
- i.guide_workflow,
409
- ' 1. Atlas (idea brief → PRD)',
410
- ' 2. Forge (architecture → code)',
411
- ' 3. Sentinel (tests → review)',
412
- '',
413
- i.guide_or_auto,
414
- '',
415
- `${i.guide_output}: _bmad-output/discovery/ & _bmad-output/build/`,
416
- '',
417
- '─'.repeat(50),
418
- '',
419
- `📦 ${i.guide_cli_title || 'CLI Commands'}:`,
420
- ` npx bmad-plus install ${i.guide_cli_install || ' Install agents & skills'}`,
421
- ` npx bmad-plus update ${i.guide_cli_update || '— Update agents (keeps config)'}`,
422
- ` npx bmad-plus doctor ${i.guide_cli_doctor || '— Check installation health'}`,
423
- ` npx bmad-plus uninstall ${i.guide_cli_uninstall || '— Remove BMAD+ from project'}`,
424
- );
425
-
426
- // Add pack-specific examples
427
- const examples = [];
428
- if (selectedPacks.includes('seo')) {
429
- examples.push(` ${i.guide_example_seo || '🔍 SEO: "/seo audit https://example.com"'}`);
430
- }
431
- if (selectedPacks.includes('backup')) {
432
- examples.push(` ${i.guide_example_backup || '🗂️ Backup: "/backup create" → ZIP timestamped'}`);
433
- }
434
- if (selectedPacks.includes('animated')) {
435
- examples.push(` ${i.guide_example_animated || '🎬 Animated: "/animated build hero.mp4"'}`);
436
- }
437
- if (selectedPacks.includes('osint')) {
438
- examples.push(` ${i.guide_example_osint || '🔍 OSINT: "Shadow, investigate John Doe"'}`);
439
- }
440
- if (selectedPacks.includes('shield')) {
441
- examples.push(
442
- ` ${i.guide_example_shield_1 || '🛡️ GRC: "Shield, audit my app for GDPR compliance"'}`,
443
- ` ${i.guide_example_shield_2 || '🛡️ GRC: "Shield, gap analysis ISO 27001 vs NIST CSF"'}`,
444
- ` ${i.guide_example_shield_3 || '🛡️ GRC: "Shield, generate SOC 2 evidence checklist"'}`,
445
- );
446
- }
447
- if (selectedPacks.includes('dev-studio')) {
448
- examples.push(
449
- ` ${i.guide_example_dev_studio_1 || '🏗️ Dev Studio: "Miriam, brainstorm a productivity app"'}`,
450
- ` ${i.guide_example_dev_studio_2 || '🏗️ Dev Studio: "Bezalel, design the architecture"'}`,
451
- ` ${i.guide_example_dev_studio_3 || '🏗️ Dev Studio: "Oholiab, implement story S1"'}`,
452
- );
453
- }
454
- if (selectedPacks.includes('memory')) {
455
- examples.push(
456
- ` ${i.guide_example_memory_1 || '🧠 Memory: "Zecher, scan projects in D:\\travail\\DEV"'}`,
457
- ` ${i.guide_example_memory_2 || '🧠 Memory: "Zecher, where were we?"'}`,
458
- ` ${i.guide_example_memory_3 || '🧠 Memory: "Zecher, consolidate memory"'}`,
459
- );
460
- }
461
-
462
- if (examples.length > 0) {
463
- agentGuide.push(
464
- '',
465
- `💡 ${i.guide_examples_title || 'Quick Examples'}:`,
466
- ...examples
467
- );
468
- }
469
-
470
- agentGuide.push(
471
- '',
472
- '---',
473
- i.guide_credits
474
- );
475
-
476
- clack.note(agentGuide.join('\n'), i.guide_title);
477
-
478
- clack.outro(pc.green(i.guide_ready));
479
- },
480
- };
481
-
482
-
483
- // ── Helpers ──
484
-
485
- function generateConfigYaml(userName, language, projectDir) {
486
- const projectName = path.basename(projectDir);
487
- return `# BMAD+ Project Configuration
488
- # Generated by bmad-plus install
489
-
490
- user_name: "${userName}"
491
- communication_language: "${language}"
492
- document_output_language: "${language}"
493
- output_folder: "_bmad-output"
494
- project_name: "${projectName}"
495
-
496
- # Execution settings
497
- execution_mode: "manual"
498
- auto_role_activation: true
499
- parallel_execution: true
500
- `;
501
- }
1
+ /**
2
+ * BMAD+ Install Command
3
+ * Installs agents, skills, and IDE configs into the current project
4
+ * Supports 10 languages: EN, FR, ES, DE, PT-BR, RU, ZH, HE, JA, IT
5
+ *
6
+ * Author: Laurent Rochetta
7
+ */
8
+
9
+ const path = require('node:path');
10
+ const fs = require('node:fs');
11
+ const fsExtra = require('fs-extra');
12
+ const clack = require('@clack/prompts');
13
+ const pc = require('picocolors');
14
+ const { t, getLanguageOptions, getCommLanguageOptions } = require('../i18n');
15
+ const { PACKS, DERIVED } = require('../lib/packs');
16
+ const { copyPackFiles, copyManagedFile } = require('../lib/pack-copy');
17
+ const { acquireProjectLock, inventoryOf, collectManagedFiles } = require('../lib/update-transaction');
18
+ const { initMemory } = require('../lib/memory-init');
19
+ const { generateUserFiles, IDE_CONFIGS } = require('../../build/generate-adapters');
20
+ const { writeIDEConfigs, safeAdapterPath } = require('../lib/installed-adapters');
21
+ const { readInstallManifest } = require('../lib/install-manifest');
22
+ const yaml = require('js-yaml');
23
+ const { validateUserName } = require('../lib/validate');
24
+ const { provisionPack } = require('../lib/python-provision');
25
+
26
+ const PYTHON_PACKS = DERIVED.pythonPacks;
27
+
28
+ module.exports = {
29
+ command: 'install',
30
+ description: 'Install BMAD+ agents and skills into your project',
31
+ options: [
32
+ ['-d, --directory <path>', 'Installation directory (default: current directory)'],
33
+ ['-p, --packs <packs>', 'Comma-separated pack IDs: core,osint,all (default: interactive)'],
34
+ ['-y, --yes', 'Accept all defaults, skip prompts'],
35
+ ['-l, --lang <code>', 'Language code: en, fr, es, de, pt-br, ru, zh, he, ja, it (overrides auto-detection)'],
36
+ ['--tools <tools>', 'Comma-separated IDE IDs, all, or none (default: auto-detect)'],
37
+ ['--mode <mode>', 'Execution mode: manual, autopilot, hybrid (default: manual)'],
38
+ ['--provision-python', 'Provision an isolated Python env for packs that need one (seo, memory)'],
39
+ ],
40
+ action: async (options) => {
41
+ // A closed/piped stdin cannot answer prompts. Require explicit defaults
42
+ // before creating files, instead of silently exiting halfway through UI.
43
+ if (!options.yes && !process.stdin.isTTY) {
44
+ const i = t(options.lang || 'en');
45
+ clack.log.error(i.noninteractive_requires_yes('install'));
46
+ process.exitCode = 1;
47
+ return;
48
+ }
49
+
50
+ const projectDir = path.resolve(options.directory || process.cwd());
51
+ const bmadSrc = path.join(__dirname, '..', '..', '..', 'src', 'bmad-plus');
52
+ const previousManifestPath = safeAdapterPath(projectDir, '_bmad/.bmad-plus-install.json');
53
+ const previousManifestBytes = fs.existsSync(previousManifestPath) ? fs.readFileSync(previousManifestPath) : null;
54
+ let previousManifest = null;
55
+ let manifestError;
56
+ if (fs.existsSync(previousManifestPath)) {
57
+ try {
58
+ previousManifest = readInstallManifest(previousManifestPath);
59
+ } catch (error) {
60
+ manifestError = error;
61
+ }
62
+ }
63
+ if (options.mode && !['manual', 'autopilot', 'hybrid'].includes(options.mode)) throw new Error('Unknown execution mode: ' + options.mode);
64
+
65
+ // ── Step 0: Language Selection ──
66
+ const pkgJson = require('../../../package.json');
67
+ clack.intro(pc.bgCyan(pc.black(` BMAD+ Installer v${pkgJson.version} `)));
68
+ clack.log.info(pc.dim('✨ Created by Laurent Rochetta — github.com/lrochetta/BMAD-PLUS'));
69
+
70
+ let lang = options.lang || 'en';
71
+ if (!options.yes && !options.lang) {
72
+ const langChoice = await clack.select({
73
+ message: '🌐 Select your language / Choisissez votre langue / 选择语言',
74
+ options: getLanguageOptions(),
75
+ });
76
+
77
+ if (clack.isCancel(langChoice)) {
78
+ clack.cancel('Installation cancelled.');
79
+ throw new Error('Installation cancelled.');
80
+ }
81
+ lang = langChoice;
82
+ }
83
+
84
+ const i = t(lang); // Get translations for selected language
85
+
86
+ // Verify source exists
87
+ if (!fs.existsSync(bmadSrc)) {
88
+ clack.log.error(`${i.source_not_found}: ${bmadSrc}`);
89
+ clack.outro(pc.red(i.failed));
90
+ throw new Error(`Source not found: ${bmadSrc}`);
91
+ }
92
+
93
+ clack.log.info(`${i.installing_to}: ${pc.cyan(projectDir)}`);
94
+
95
+ // ── Step 1: Pack Selection ──
96
+ let selectedPacks = ['core']; // Core always included
97
+
98
+ if (options.packs) {
99
+ const requested = options.packs.split(',').map(p => p.trim());
100
+ if (requested.includes('all')) {
101
+ selectedPacks = Object.keys(PACKS).filter(k => !PACKS[k].disabled);
102
+ } else {
103
+ selectedPacks = [...new Set(['core', ...requested.filter(p => PACKS[p] && !PACKS[p].disabled)])];
104
+ }
105
+ } else if (!options.yes) {
106
+ const packChoice = await clack.multiselect({
107
+ message: i.select_packs,
108
+ options: Object.entries(PACKS)
109
+ .filter(([, p]) => !p.required)
110
+ .map(([key, pack]) => ({
111
+ value: key,
112
+ label: `${pack.icon} ${pack.name}`,
113
+ hint: pack.disabled ? i.soon : (pack.desc || pack.description || ''),
114
+ disabled: pack.disabled,
115
+ })),
116
+ required: false,
117
+ });
118
+
119
+ if (clack.isCancel(packChoice)) {
120
+ clack.cancel(i.cancelled);
121
+ throw new Error(i.cancelled);
122
+ }
123
+
124
+ selectedPacks = [...new Set(['core', ...packChoice])];
125
+ }
126
+
127
+ clack.log.success(`${i.selected_packs}: ${selectedPacks.map(p => `${PACKS[p].icon} ${PACKS[p].name}`).join(', ')}`);
128
+
129
+ // ── Step 2: IDE Detection ──
130
+ let detectedIDEs = [];
131
+
132
+ if (options.tools) {
133
+ if (options.tools === 'none' || options.tools === 'skip') {
134
+ detectedIDEs = [];
135
+ } else if (options.tools === 'all') {
136
+ detectedIDEs = Object.keys(IDE_CONFIGS);
137
+ } else {
138
+ detectedIDEs = options.tools.split(',').map(t => t.trim()).filter(t => IDE_CONFIGS[t]);
139
+ }
140
+ } else {
141
+ // Auto-detect
142
+ for (const [id, ide] of Object.entries(IDE_CONFIGS)) {
143
+ for (const marker of ide.detect) {
144
+ if (fs.existsSync(path.join(projectDir, marker))) {
145
+ detectedIDEs.push(id);
146
+ break;
147
+ }
148
+ }
149
+ }
150
+
151
+ // If nothing detected, ask
152
+ if (detectedIDEs.length === 0 && !options.yes) {
153
+ const ideChoice = await clack.multiselect({
154
+ message: i.select_ide,
155
+ options: Object.entries(IDE_CONFIGS).map(([key, ide]) => ({
156
+ value: key,
157
+ label: ide.name,
158
+ })),
159
+ required: false,
160
+ });
161
+
162
+ if (!clack.isCancel(ideChoice)) {
163
+ detectedIDEs = ideChoice;
164
+ }
165
+ }
166
+
167
+ // Default to all if --yes
168
+ if (detectedIDEs.length === 0 && options.yes) {
169
+ detectedIDEs = Object.keys(IDE_CONFIGS);
170
+ }
171
+ }
172
+
173
+ if (detectedIDEs.length > 0) {
174
+ clack.log.info(`${i.detected_ides}: ${detectedIDEs.map(id => IDE_CONFIGS[id].name).join(', ')}`);
175
+ } else if (options.tools === 'none' || options.tools === 'skip') {
176
+ clack.log.info(pc.dim('⏭️ IDE config skipped (--tools none) existing configs preserved'));
177
+ }
178
+
179
+ // ── Step 3: User Config ──
180
+ let userName = process.env.USER || process.env.USERNAME || 'Developer';
181
+ let commLang = 'French';
182
+ let execMode = options.mode || 'manual';
183
+
184
+ if (!options.yes) {
185
+ const userConfig = await clack.group({
186
+ userName: () => clack.text({
187
+ message: i.enter_name,
188
+ placeholder: userName,
189
+ defaultValue: userName,
190
+ }),
191
+ commLang: () => clack.select({
192
+ message: i.comm_language,
193
+ options: getCommLanguageOptions(),
194
+ }),
195
+ execMode: () => clack.select({
196
+ message: i.exec_mode,
197
+ options: [
198
+ { value: 'manual', label: i.exec_manual },
199
+ { value: 'autopilot', label: i.exec_autopilot },
200
+ { value: 'hybrid', label: i.exec_hybrid },
201
+ ],
202
+ }),
203
+ });
204
+
205
+ if (clack.isCancel(userConfig)) {
206
+ clack.cancel(i.cancelled);
207
+ throw new Error(i.cancelled);
208
+ }
209
+
210
+ // Validate user-provided name
211
+ const rawName = userConfig.userName;
212
+ const fb = process.env.USER || process.env.USERNAME || 'Developer';
213
+ const { name: validatedName, warnings } = validateUserName(rawName, fb);
214
+ for (const w of warnings) clack.log.warn(w);
215
+ userName = validatedName;
216
+ commLang = userConfig.commLang;
217
+ execMode = options.mode || userConfig.execMode;
218
+ }
219
+
220
+ const releaseLock = acquireProjectLock(projectDir);
221
+ try {
222
+ const { safeTarget } = require('../../build/generate-adapters');
223
+ const plannedFiles = collectManagedFiles({ projectDir, packs: selectedPacks });
224
+ if (detectedIDEs.length) plannedFiles.push(...generateUserFiles(DERIVED, {
225
+ packs: selectedPacks, tools: detectedIDEs, userName, language: commLang,
226
+ }));
227
+ for (const { file } of plannedFiles) safeTarget(projectDir, file);
228
+ safeTarget(projectDir, '_bmad/config.yaml');
229
+ safeTarget(projectDir, '_bmad/.bmad-plus-install.json');
230
+ for (const directory of ['.agents/skills', '.agents/data', '_bmad', '_bmad-output/discovery', '_bmad-output/build', 'docs']) {
231
+ safeTarget(projectDir, directory + '/.bmad-preflight');
232
+ }
233
+ const currentManifestBytes = fs.existsSync(previousManifestPath) ? fs.readFileSync(previousManifestPath) : null;
234
+ if (previousManifestBytes === null ? currentManifestBytes !== null :
235
+ currentManifestBytes === null || !previousManifestBytes.equals(currentManifestBytes)) {
236
+ throw new Error('Installation changed while preparing install. Please retry.');
237
+ }
238
+ // Preserve the unreadable manifest before repair; do not trust its ownership
239
+ // hashes. The adapter writer will retain locally edited user instructions.
240
+ if (manifestError) {
241
+ const backupBase = '_bmad/.bmad-plus-install.json.corrupt.bak';
242
+ let backupFile = backupBase;
243
+ let index = 1;
244
+ while (fs.existsSync(safeAdapterPath(projectDir, backupFile))) backupFile = `${backupBase}.${index++}`;
245
+ const backupPath = safeAdapterPath(projectDir, backupFile);
246
+ fs.copyFileSync(safeAdapterPath(projectDir, '_bmad/.bmad-plus-install.json'), backupPath, fs.constants.COPYFILE_EXCL);
247
+ clack.log.warn(`${i.manifest_invalid(manifestError.message)}\nBackup: ${backupPath}`);
248
+ }
249
+
250
+ // ── Step 4: Install Files ──
251
+ const spinner = clack.spinner();
252
+ spinner.start(i.installing_files);
253
+
254
+ const targetAgentsDir = path.join(projectDir, '.agents', 'skills');
255
+ const targetDataDir = path.join(projectDir, '.agents', 'data');
256
+ const targetBmadDir = path.join(projectDir, '_bmad');
257
+
258
+ // Create directories
259
+ fsExtra.ensureDirSync(targetAgentsDir);
260
+ fsExtra.ensureDirSync(targetDataDir);
261
+ fsExtra.ensureDirSync(targetBmadDir);
262
+
263
+ let copiedAgents = 0;
264
+ let copiedSkills = 0;
265
+ let copiedFiles = 0;
266
+ const previousInventory = inventoryOf(previousManifest || {}) || {};
267
+ const fileInventory = { ...previousInventory };
268
+ let inventoryComplete = true;
269
+ const onFileConflict = file => {
270
+ if (!previousInventory[file]) inventoryComplete = false;
271
+ clack.log.warn(`${file}: locally changed or unowned content preserved.`);
272
+ };
273
+
274
+ const projectRoot = path.join(bmadSrc, '..', '..');
275
+
276
+ for (const packId of selectedPacks) {
277
+ const pack = PACKS[packId];
278
+ if (!pack || pack.disabled) continue;
279
+
280
+ const result = copyPackFiles({
281
+ bmadSrc,
282
+ targetAgentsDir,
283
+ targetDataDir,
284
+ projectRoot,
285
+ pack,
286
+ projectDir, inventory: fileInventory, previousInventory, onConflict: onFileConflict,
287
+ });
288
+ copiedAgents += result.copiedAgents;
289
+ copiedSkills += result.copiedSkills;
290
+ copiedFiles += result.copiedFiles;
291
+
292
+ // Memory pack: initialize brain with existing brain detection.
293
+ // Non-fatal: a read-only or missing home dir (containers, CI) must not
294
+ // abort the install mid-flight and leave a manifest-less partial tree.
295
+ if (packId === 'memory' && pack.packDir) {
296
+ try {
297
+ initMemory({ projectDir, bmadSrc, userName, commLang, selectedPacks });
298
+ } catch (err) {
299
+ clack.log.warn(`Memory/brain initialization failed (non-fatal, install continues): ${err.message}`);
300
+ }
301
+ }
302
+ }
303
+
304
+ // ── Python provisioning (opt-in) — for packs whose runtime needs Python ──
305
+ // Off by default so `install` never spawns Python unless asked. Closes the
306
+ // "SEO pack ships prompts that call scripts never installed" gap (PROD-02).
307
+ if (options.provisionPython) {
308
+ const pythonPacks = selectedPacks.filter((p) => PYTHON_PACKS[p]);
309
+ for (const packId of pythonPacks) {
310
+ const cfg = PYTHON_PACKS[packId];
311
+ const requirementsPath = path.join(projectRoot, ...cfg.requirements);
312
+ if (!fs.existsSync(requirementsPath)) {
313
+ clack.log.warn(`Python provisioning skipped for ${packId}: ${requirementsPath} not found.`);
314
+ continue;
315
+ }
316
+ const pySpinner = clack.spinner();
317
+ pySpinner.start(`Provisioning Python runtime for ${PACKS[packId].name}…`);
318
+ const res = provisionPack({
319
+ envDir: path.join(projectDir, '.bmad', 'venv', packId),
320
+ requirementsPath,
321
+ verifyModules: cfg.verifyModules,
322
+ });
323
+ pySpinner.stop(
324
+ res.ok
325
+ ? `${PACKS[packId].name}: Python runtime ready (${res.tool}).`
326
+ : `${PACKS[packId].name}: Python not provisioned — ${res.messages[res.messages.length - 1] || 'see guidance'}`
327
+ );
328
+ if (!res.ok) {
329
+ clack.log.warn(`Run \`${PACKS[packId].name}\` Python tools after installing Python ≥3.11; the pack's prompts still work, only the local scripts need the runtime.`);
330
+ }
331
+ }
332
+ }
333
+
334
+ // Copy module config
335
+ const moduleYaml = path.join(bmadSrc, 'module.yaml');
336
+ if (fs.existsSync(moduleYaml)) {
337
+ copyManagedFile({ source: moduleYaml, target: path.join(targetBmadDir, 'module.yaml'),
338
+ projectDir, inventory: fileInventory, previousInventory, onConflict: onFileConflict });
339
+ copiedFiles++;
340
+ }
341
+
342
+ const helpCsv = path.join(bmadSrc, 'module-help.csv');
343
+ if (fs.existsSync(helpCsv)) {
344
+ copyManagedFile({ source: helpCsv, target: path.join(targetBmadDir, 'module-help.csv'),
345
+ projectDir, inventory: fileInventory, previousInventory, onConflict: onFileConflict });
346
+ copiedFiles++;
347
+ }
348
+
349
+ spinner.stop(i.installed_summary(copiedAgents, copiedSkills, copiedFiles));
350
+
351
+ // ── Step 5: Generate IDE Configs ──
352
+ let adapterHashes = previousManifest?.adapterHashes || {};
353
+ if (detectedIDEs.length > 0) {
354
+ const ideSpinner = clack.spinner();
355
+ ideSpinner.start(i.configuring_ides);
356
+
357
+ const outcome = writeIDEConfigs({
358
+ projectDir,
359
+ files: generateUserFiles(DERIVED, { packs: selectedPacks, userName, language: commLang, tools: detectedIDEs }),
360
+ adapterHashes,
361
+ yes: options.yes,
362
+ });
363
+ adapterHashes = { ...adapterHashes, ...outcome.adapterHashes };
364
+
365
+ ideSpinner.stop(i.ide_configured(detectedIDEs.length));
366
+ }
367
+
368
+ // ── Step 6: Create config.yaml ──
369
+ const configYaml = generateConfigYaml(userName, commLang, projectDir, execMode);
370
+ const configPath = path.join(targetBmadDir, 'config.yaml');
371
+ fs.writeFileSync(configPath, configYaml, 'utf8');
372
+
373
+ // ── Step 7: Create output directories ──
374
+ const outputDir = path.join(projectDir, '_bmad-output');
375
+ fsExtra.ensureDirSync(path.join(outputDir, 'discovery'));
376
+ fsExtra.ensureDirSync(path.join(outputDir, 'build'));
377
+ fsExtra.ensureDirSync(path.join(projectDir, 'docs'));
378
+
379
+ // ── Step 8: Write install manifest ──
380
+ const pkgVersion = require('../../../package.json').version;
381
+ const manifest = {
382
+ version: pkgVersion,
383
+ uiLanguage: lang,
384
+ installed: new Date().toISOString(),
385
+ packs: selectedPacks,
386
+ ides: detectedIDEs,
387
+ adapterHashes,
388
+ fileInventory: { schemaVersion: 1, complete: inventoryComplete, files: fileInventory },
389
+ executionMode: execMode,
390
+ user: userName,
391
+ language: commLang,
392
+ };
393
+ fs.writeFileSync(
394
+ path.join(targetBmadDir, '.bmad-plus-install.json'),
395
+ JSON.stringify(manifest, null, 2),
396
+ 'utf8'
397
+ );
398
+
399
+ // ── Summary Contextual Getting Started ──
400
+ const agentGuide = [
401
+ i.guide_who,
402
+ '',
403
+ ` ${i.guide_idea.padEnd(28)} → "Atlas, [...]"`,
404
+ ` ${i.guide_prd.padEnd(28)} → "Atlas, create PRD"`,
405
+ ` ${i.guide_arch.padEnd(28)} → "Forge, propose architecture"`,
406
+ ` ${i.guide_code.padEnd(28)} → "Forge, implement story [X]"`,
407
+ ` ${i.guide_test.padEnd(28)} → "Sentinel, review module [X]"`,
408
+ ` ${i.guide_sprint.padEnd(28)} → "Nexus, create epics"`,
409
+ ` ${i.guide_auto.padEnd(28)} "autopilot"`,
410
+ ];
411
+
412
+ if (selectedPacks.includes('osint')) {
413
+ agentGuide.push(` ${i.guide_osint.padEnd(28)} → "Shadow, investigate [name]"`);
414
+ }
415
+
416
+ if (selectedPacks.includes('maker')) {
417
+ agentGuide.push(` ${i.guide_maker.padEnd(28)} → "Maker, create agent [desc]"`);
418
+ }
419
+
420
+ if (selectedPacks.includes('seo')) {
421
+ agentGuide.push(` ${i.guide_seo.padEnd(28)} → "/seo audit <url>"`);
422
+ }
423
+
424
+ if (selectedPacks.includes('backup')) {
425
+ agentGuide.push(` ${i.guide_backup.padEnd(28)} → "/backup create"`);
426
+ }
427
+
428
+ if (selectedPacks.includes('animated')) {
429
+ agentGuide.push(` ${i.guide_animated.padEnd(28)} "/animated build <video>"`);
430
+ }
431
+
432
+ if (selectedPacks.includes('shield')) {
433
+ agentGuide.push(` ${(i.guide_shield || '🛡️ GRC Compliance').padEnd(28)} → "Shield, audit my SaaS for GDPR"`);
434
+ }
435
+
436
+ if (selectedPacks.includes('memory')) {
437
+ agentGuide.push(` ${(i.guide_memory || '🧠 Memory Brain').padEnd(28)} → "Zecher, scan projects in [path]"`);
438
+ }
439
+
440
+ if (selectedPacks.includes('dev-studio')) {
441
+ agentGuide.push(` ${(i.guide_dev_studio || '🏗️ Dev Studio').padEnd(28)} → "Miriam, brainstorm my app idea"`);
442
+ }
443
+
444
+ agentGuide.push(
445
+ '',
446
+ i.guide_workflow,
447
+ ' 1. Atlas (idea → brief → PRD)',
448
+ ' 2. Forge (architecture → code)',
449
+ ' 3. Sentinel (tests review)',
450
+ '',
451
+ i.guide_or_auto,
452
+ '',
453
+ `${i.guide_output}: _bmad-output/discovery/ & _bmad-output/build/`,
454
+ '',
455
+ '─'.repeat(50),
456
+ '',
457
+ `📦 ${i.guide_cli_title || 'CLI Commands'}:`,
458
+ ` npx bmad-plus install ${i.guide_cli_install || ' Install agents & skills'}`,
459
+ ` npx bmad-plus update ${i.guide_cli_update || '— Update agents (keeps config)'}`,
460
+ ` npx bmad-plus doctor ${i.guide_cli_doctor || '— Check installation health'}`,
461
+ ` npx bmad-plus uninstall ${i.guide_cli_uninstall || '— Remove BMAD+ from project'}`,
462
+ );
463
+
464
+ // Add pack-specific examples
465
+ const examples = [];
466
+ if (selectedPacks.includes('seo')) {
467
+ examples.push(` ${i.guide_example_seo || '🔍 SEO: "/seo audit https://example.com"'}`);
468
+ }
469
+ if (selectedPacks.includes('backup')) {
470
+ examples.push(` ${i.guide_example_backup || '🗂️ Backup: "/backup create" → ZIP timestamped'}`);
471
+ }
472
+ if (selectedPacks.includes('animated')) {
473
+ examples.push(` ${i.guide_example_animated || '🎬 Animated: "/animated build hero.mp4"'}`);
474
+ }
475
+ if (selectedPacks.includes('osint')) {
476
+ examples.push(` ${i.guide_example_osint || '🔍 OSINT: "Shadow, investigate John Doe"'}`);
477
+ }
478
+ if (selectedPacks.includes('shield')) {
479
+ examples.push(
480
+ ` ${i.guide_example_shield_1 || '🛡️ GRC: "Shield, audit my app for GDPR compliance"'}`,
481
+ ` ${i.guide_example_shield_2 || '🛡️ GRC: "Shield, gap analysis ISO 27001 vs NIST CSF"'}`,
482
+ ` ${i.guide_example_shield_3 || '🛡️ GRC: "Shield, generate SOC 2 evidence checklist"'}`,
483
+ );
484
+ }
485
+ if (selectedPacks.includes('dev-studio')) {
486
+ examples.push(
487
+ ` ${i.guide_example_dev_studio_1 || '🏗️ Dev Studio: "Miriam, brainstorm a productivity app"'}`,
488
+ ` ${i.guide_example_dev_studio_2 || '🏗️ Dev Studio: "Bezalel, design the architecture"'}`,
489
+ ` ${i.guide_example_dev_studio_3 || '🏗️ Dev Studio: "Oholiab, implement story S1"'}`,
490
+ );
491
+ }
492
+ if (selectedPacks.includes('memory')) {
493
+ examples.push(
494
+ ` ${i.guide_example_memory_1 || '🧠 Memory: "Zecher, scan projects in D:\\travail\\DEV"'}`,
495
+ ` ${i.guide_example_memory_2 || '🧠 Memory: "Zecher, where were we?"'}`,
496
+ ` ${i.guide_example_memory_3 || '🧠 Memory: "Zecher, consolidate memory"'}`,
497
+ );
498
+ }
499
+
500
+ if (examples.length > 0) {
501
+ agentGuide.push(
502
+ '',
503
+ `💡 ${i.guide_examples_title || 'Quick Examples'}:`,
504
+ ...examples
505
+ );
506
+ }
507
+
508
+ agentGuide.push(
509
+ '',
510
+ '---',
511
+ i.guide_credits
512
+ );
513
+
514
+ clack.note(agentGuide.join('\n'), i.guide_title);
515
+
516
+ clack.outro(pc.green(i.guide_ready));
517
+ } finally {
518
+ releaseLock();
519
+ }
520
+ },
521
+ // Exported for functional testing (not part of the public API)
522
+ _internal: { writeIDEConfigs, generateConfigYaml },
523
+ };
524
+
525
+ function generateConfigYaml(userName, language, projectDir, execMode = 'manual') {
526
+ if (!['manual', 'autopilot', 'hybrid'].includes(execMode)) throw new Error('Unknown execution mode: ' + execMode);
527
+ return '# BMAD+ Project Configuration\n# Generated by bmad-plus install\n\n' + yaml.dump({
528
+ user_name: userName,
529
+ communication_language: language,
530
+ document_output_language: language,
531
+ output_folder: '_bmad-output',
532
+ project_name: path.basename(projectDir),
533
+ execution_mode: execMode,
534
+ auto_role_activation: true,
535
+ parallel_execution: true,
536
+ checkpoints: {
537
+ discovery: 'require_approval',
538
+ architecture: 'require_approval',
539
+ story: execMode === 'autopilot' ? 'notify_only' : 'require_approval',
540
+ delivery: 'require_approval',
541
+ },
542
+ }, { lineWidth: -1, forceQuotes: true, quotingType: '"' });
543
+ }