bmad-plus 0.12.1 → 0.12.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (156) hide show
  1. package/CHANGELOG.md +612 -580
  2. package/README.md +90 -115
  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 +104 -91
  14. package/readme-international/README.de.md +596 -594
  15. package/readme-international/README.es.md +613 -611
  16. package/readme-international/README.fr.md +611 -609
  17. package/src/bmad-plus/agents/agent-shadow/SKILL.md +18 -0
  18. package/src/bmad-plus/data/role-triggers.yaml +52 -0
  19. package/src/bmad-plus/module.yaml +283 -283
  20. package/src/bmad-plus/packs/pack-animated/animated-website-agent.md +325 -325
  21. package/src/bmad-plus/packs/pack-animated/templates/animated-website-workflow.md +55 -55
  22. package/src/bmad-plus/packs/pack-backup/backup-agent.md +71 -71
  23. package/src/bmad-plus/packs/pack-backup/templates/backup-workflow.md +51 -51
  24. package/src/bmad-plus/packs/pack-dev-studio/README.md +162 -162
  25. package/src/bmad-plus/packs/pack-dev-studio/categories/analysis/analyst-agent.md +73 -73
  26. package/src/bmad-plus/packs/pack-dev-studio/categories/analysis/document-project.md +61 -61
  27. package/src/bmad-plus/packs/pack-dev-studio/categories/analysis/domain-research.md +95 -95
  28. package/src/bmad-plus/packs/pack-dev-studio/categories/analysis/market-research.md +95 -95
  29. package/src/bmad-plus/packs/pack-dev-studio/categories/analysis/prfaq.md +134 -134
  30. package/src/bmad-plus/packs/pack-dev-studio/categories/analysis/product-brief.md +80 -80
  31. package/src/bmad-plus/packs/pack-dev-studio/categories/analysis/tech-writer-agent.md +73 -73
  32. package/src/bmad-plus/packs/pack-dev-studio/categories/analysis/technical-research.md +95 -95
  33. package/src/bmad-plus/packs/pack-dev-studio/categories/architecture/architect-agent.md +73 -73
  34. package/src/bmad-plus/packs/pack-dev-studio/categories/architecture/create-architecture.md +73 -73
  35. package/src/bmad-plus/packs/pack-dev-studio/categories/architecture/create-epics-stories.md +92 -92
  36. package/src/bmad-plus/packs/pack-dev-studio/categories/architecture/generate-project-context.md +80 -80
  37. package/src/bmad-plus/packs/pack-dev-studio/categories/architecture/implementation-readiness.md +90 -90
  38. package/src/bmad-plus/packs/pack-dev-studio/categories/architecture/steps/step-01-init.md +153 -153
  39. package/src/bmad-plus/packs/pack-dev-studio/categories/architecture/steps/step-01b-continue.md +173 -173
  40. package/src/bmad-plus/packs/pack-dev-studio/categories/architecture/steps/step-02-context.md +224 -224
  41. package/src/bmad-plus/packs/pack-dev-studio/categories/architecture/steps/step-03-starter.md +329 -329
  42. package/src/bmad-plus/packs/pack-dev-studio/categories/architecture/steps/step-04-decisions.md +318 -318
  43. package/src/bmad-plus/packs/pack-dev-studio/categories/architecture/steps/step-05-patterns.md +359 -359
  44. package/src/bmad-plus/packs/pack-dev-studio/categories/architecture/steps/step-06-structure.md +379 -379
  45. package/src/bmad-plus/packs/pack-dev-studio/categories/architecture/steps/step-07-validation.md +361 -361
  46. package/src/bmad-plus/packs/pack-dev-studio/categories/architecture/steps/step-08-complete.md +81 -81
  47. package/src/bmad-plus/packs/pack-dev-studio/categories/implementation/checkpoint-preview.md +67 -67
  48. package/src/bmad-plus/packs/pack-dev-studio/categories/implementation/code-review-steps/step-01-gather-context.md +85 -85
  49. package/src/bmad-plus/packs/pack-dev-studio/categories/implementation/code-review-steps/step-02-review.md +35 -35
  50. package/src/bmad-plus/packs/pack-dev-studio/categories/implementation/code-review-steps/step-03-triage.md +49 -49
  51. package/src/bmad-plus/packs/pack-dev-studio/categories/implementation/code-review-steps/step-04-present.md +131 -131
  52. package/src/bmad-plus/packs/pack-dev-studio/categories/implementation/code-review.md +89 -89
  53. package/src/bmad-plus/packs/pack-dev-studio/categories/implementation/correct-course.md +300 -300
  54. package/src/bmad-plus/packs/pack-dev-studio/categories/implementation/create-story.md +428 -428
  55. package/src/bmad-plus/packs/pack-dev-studio/categories/implementation/dev-agent.md +73 -73
  56. package/src/bmad-plus/packs/pack-dev-studio/categories/implementation/dev-story-checklist.md +80 -80
  57. package/src/bmad-plus/packs/pack-dev-studio/categories/implementation/dev-story.md +484 -484
  58. package/src/bmad-plus/packs/pack-dev-studio/categories/implementation/investigate.md +193 -193
  59. package/src/bmad-plus/packs/pack-dev-studio/categories/implementation/qa-e2e-tests.md +175 -175
  60. package/src/bmad-plus/packs/pack-dev-studio/categories/implementation/quick-dev.md +110 -110
  61. package/src/bmad-plus/packs/pack-dev-studio/categories/implementation/retrospective.md +1511 -1511
  62. package/src/bmad-plus/packs/pack-dev-studio/categories/implementation/sprint-planning.md +298 -298
  63. package/src/bmad-plus/packs/pack-dev-studio/categories/implementation/sprint-status.md +296 -296
  64. package/src/bmad-plus/packs/pack-dev-studio/categories/planning/create-prd.md +29 -29
  65. package/src/bmad-plus/packs/pack-dev-studio/categories/planning/create-ux-design.md +74 -74
  66. package/src/bmad-plus/packs/pack-dev-studio/categories/planning/edit-prd.md +29 -29
  67. package/src/bmad-plus/packs/pack-dev-studio/categories/planning/pm-agent.md +73 -73
  68. package/src/bmad-plus/packs/pack-dev-studio/categories/planning/prd.md +89 -89
  69. package/src/bmad-plus/packs/pack-dev-studio/categories/planning/ux-designer-agent.md +73 -73
  70. package/src/bmad-plus/packs/pack-dev-studio/categories/planning/validate-prd.md +29 -29
  71. package/src/bmad-plus/packs/pack-dev-studio/categories/utilities/advanced-elicitation.md +141 -141
  72. package/src/bmad-plus/packs/pack-dev-studio/categories/utilities/adversarial-review.md +37 -37
  73. package/src/bmad-plus/packs/pack-dev-studio/categories/utilities/bmad-help.md +75 -75
  74. package/src/bmad-plus/packs/pack-dev-studio/categories/utilities/brainstorming.md +6 -6
  75. package/src/bmad-plus/packs/pack-dev-studio/categories/utilities/customize.md +110 -110
  76. package/src/bmad-plus/packs/pack-dev-studio/categories/utilities/distillator.md +176 -176
  77. package/src/bmad-plus/packs/pack-dev-studio/categories/utilities/edge-case-hunter.md +67 -67
  78. package/src/bmad-plus/packs/pack-dev-studio/categories/utilities/editorial-review-prose.md +86 -86
  79. package/src/bmad-plus/packs/pack-dev-studio/categories/utilities/editorial-review-structure.md +179 -179
  80. package/src/bmad-plus/packs/pack-dev-studio/categories/utilities/index-docs.md +66 -66
  81. package/src/bmad-plus/packs/pack-dev-studio/categories/utilities/party-mode.md +127 -127
  82. package/src/bmad-plus/packs/pack-dev-studio/categories/utilities/shard-doc.md +105 -105
  83. package/src/bmad-plus/packs/pack-dev-studio/dev-studio-orchestrator.md +120 -120
  84. package/src/bmad-plus/packs/pack-dev-studio/shared/architecture-decision-template.md +12 -12
  85. package/src/bmad-plus/packs/pack-dev-studio/shared/bwml-spec.md +328 -328
  86. package/src/bmad-plus/packs/pack-dev-studio/shared/module-help.csv +32 -32
  87. package/src/bmad-plus/packs/pack-dev-studio/upstream-sync.yaml +81 -81
  88. package/src/bmad-plus/packs/pack-seo/SKILL.md +171 -171
  89. package/src/bmad-plus/packs/pack-seo/checklist.md +140 -140
  90. package/src/bmad-plus/packs/pack-seo/pagespeed-playbook.md +320 -320
  91. package/src/bmad-plus/packs/pack-seo/ref/audit-schema.json +187 -187
  92. package/src/bmad-plus/packs/pack-seo/ref/cwv-thresholds.md +87 -87
  93. package/src/bmad-plus/packs/pack-seo/ref/eeat-criteria.md +123 -123
  94. package/src/bmad-plus/packs/pack-seo/ref/geo-signals.md +167 -167
  95. package/src/bmad-plus/packs/pack-seo/ref/hreflang-rules.md +153 -153
  96. package/src/bmad-plus/packs/pack-seo/ref/quality-gates.md +133 -133
  97. package/src/bmad-plus/packs/pack-seo/ref/schema-catalog.md +91 -91
  98. package/src/bmad-plus/packs/pack-seo/ref/schema-templates.json +356 -356
  99. package/src/bmad-plus/packs/pack-seo/requirements.txt +17 -0
  100. package/src/bmad-plus/packs/pack-seo/scripts/seo_apis.py +456 -0
  101. package/src/bmad-plus/packs/pack-seo/scripts/seo_crawl.py +359 -0
  102. package/src/bmad-plus/packs/pack-seo/scripts/seo_fetch.py +304 -0
  103. package/src/bmad-plus/packs/pack-seo/scripts/seo_parse.py +255 -0
  104. package/src/bmad-plus/packs/pack-seo/scripts/seo_report.py +410 -0
  105. package/src/bmad-plus/packs/pack-seo/scripts/seo_screenshot.py +202 -0
  106. package/src/bmad-plus/packs/pack-seo/seo-chief.md +294 -294
  107. package/src/bmad-plus/packs/pack-seo/seo-judge.md +241 -241
  108. package/src/bmad-plus/packs/pack-seo/seo-scout.md +171 -171
  109. package/src/bmad-plus/packs/pack-seo/templates/seo-audit-workflow.md +241 -241
  110. package/src/bmad-plus/packs/pack-shield/README.md +6 -6
  111. package/src/bmad-plus/packs/pack-shield/SKILL.md +2 -2
  112. package/src/bmad-plus/packs/pack-shield/categories/accessibility-esg/csrd-agent.md +11 -11
  113. package/src/bmad-plus/packs/pack-shield/categories/accessibility-esg/section508-agent.md +11 -11
  114. package/src/bmad-plus/packs/pack-shield/categories/accessibility-esg/wcag-agent.md +11 -11
  115. package/src/bmad-plus/packs/pack-shield/categories/ai-governance/eu-ai-act-agent.md +11 -11
  116. package/src/bmad-plus/packs/pack-shield/categories/ai-governance/iso42001-agent.md +11 -11
  117. package/src/bmad-plus/packs/pack-shield/categories/ai-governance/nist-ai-rmf-agent.md +11 -11
  118. package/src/bmad-plus/packs/pack-shield/categories/cybersecurity/cis-controls-agent.md +11 -11
  119. package/src/bmad-plus/packs/pack-shield/categories/cybersecurity/ism-agent.md +11 -11
  120. package/src/bmad-plus/packs/pack-shield/categories/cybersecurity/iso27001-agent.md +11 -11
  121. package/src/bmad-plus/packs/pack-shield/categories/cybersecurity/nis2-agent.md +11 -11
  122. package/src/bmad-plus/packs/pack-shield/categories/cybersecurity/nist-800-53-agent.md +11 -11
  123. package/src/bmad-plus/packs/pack-shield/categories/cybersecurity/nist-csf-agent.md +11 -11
  124. package/src/bmad-plus/packs/pack-shield/categories/defense-export/cmmc-agent.md +11 -11
  125. package/src/bmad-plus/packs/pack-shield/categories/defense-export/ear-agent.md +11 -11
  126. package/src/bmad-plus/packs/pack-shield/categories/defense-export/itar-agent.md +11 -11
  127. package/src/bmad-plus/packs/pack-shield/categories/defense-export/tsa-agent.md +11 -11
  128. package/src/bmad-plus/packs/pack-shield/categories/industry-compliance/dora-agent.md +11 -11
  129. package/src/bmad-plus/packs/pack-shield/categories/industry-compliance/fedramp-agent.md +11 -11
  130. package/src/bmad-plus/packs/pack-shield/categories/industry-compliance/hipaa-agent.md +11 -11
  131. package/src/bmad-plus/packs/pack-shield/categories/industry-compliance/pci-dss-agent.md +11 -11
  132. package/src/bmad-plus/packs/pack-shield/categories/industry-compliance/soc2-agent.md +11 -11
  133. package/src/bmad-plus/packs/pack-shield/categories/industry-compliance/swift-csp-agent.md +11 -11
  134. package/src/bmad-plus/packs/pack-shield/shield-orchestrator.md +1 -1
  135. package/tools/build/check-counts.js +628 -0
  136. package/tools/build/generated-adapters/.codex/AGENTS.md +1 -1
  137. package/tools/build/generated-adapters/.cursor/rules/bmad-plus.mdc +1 -1
  138. package/tools/build/generated-adapters/.opencode/AGENTS.md +1 -1
  139. package/tools/build/generated-adapters/AGENTS.md +1 -1
  140. package/tools/build/generated-adapters/CLAUDE.md +1 -1
  141. package/tools/build/generated-adapters/CONVENTIONS.md +1 -1
  142. package/tools/build/generated-adapters/GEMINI.md +1 -1
  143. package/tools/cli/commands/autoconfig.js +470 -470
  144. package/tools/cli/commands/doctor.js +233 -233
  145. package/tools/cli/commands/install.js +598 -501
  146. package/tools/cli/commands/memory-journal-cmd.js +311 -311
  147. package/tools/cli/commands/memory.js +195 -195
  148. package/tools/cli/commands/scan.js +348 -348
  149. package/tools/cli/commands/uninstall.js +101 -101
  150. package/tools/cli/commands/update.js +134 -134
  151. package/tools/cli/i18n.js +845 -845
  152. package/tools/cli/lib/README-memory-journal.md +125 -125
  153. package/tools/cli/lib/ide-config.js +267 -259
  154. package/tools/cli/lib/python-provision.js +508 -508
  155. package/tools/cli/lib/stack-detect.js +102 -102
  156. package/tools/cli/lib/validate.js +50 -50
@@ -1,470 +1,470 @@
1
- /**
2
- * BMAD+ Autoconfig Command
3
- * Smart project bootstrap — analyzes existing projects or guides new ones.
4
- * Auto-detects stack, selects best packs, installs, populates memory.
5
- *
6
- * Author: Laurent Rochetta
7
- */
8
-
9
- const path = require('node:path');
10
- const fs = require('node:fs');
11
- const clack = require('@clack/prompts');
12
- const pc = require('picocolors');
13
- const { detectStack } = require('../lib/stack-detect');
14
- const { IDE_CONFIGS } = require('../lib/ide-config');
15
-
16
- // ── Project Analysis Engine ──
17
-
18
- function analyzeStructure(dir) {
19
- const structure = {
20
- hasSrc: false,
21
- hasTests: false,
22
- hasDocs: false,
23
- hasCI: false,
24
- hasDocker: false,
25
- hasConfig: false,
26
- hasLicense: false,
27
- hasReadme: false,
28
- hasGit: false,
29
- hasEnv: false,
30
- hasBmad: false,
31
- hasIdeConfigs: [],
32
- fileCount: 0,
33
- directories: [],
34
- };
35
-
36
- try {
37
- const entries = fs.readdirSync(dir, { withFileTypes: true });
38
-
39
- for (const entry of entries) {
40
- if (entry.isDirectory()) {
41
- const name = entry.name.toLowerCase();
42
- if (name === 'src' || name === 'lib' || name === 'app') structure.hasSrc = true;
43
- if (name === 'tests' || name === 'test' || name === '__tests__' || name === 'spec') structure.hasTests = true;
44
- if (name === 'docs' || name === 'doc' || name === 'documentation') structure.hasDocs = true;
45
- if (name === '.github' || name === '.gitlab-ci' || name === '.circleci') structure.hasCI = true;
46
- if (name === '.agents' || name === '_bmad') structure.hasBmad = true;
47
- if (!name.startsWith('.') && name !== 'node_modules') structure.directories.push(entry.name);
48
- } else {
49
- structure.fileCount++;
50
- const name = entry.name;
51
- if (name === 'Dockerfile' || name === 'docker-compose.yml' || name === 'docker-compose.yaml') structure.hasDocker = true;
52
- if (name === 'LICENSE' || name === 'LICENSE.md') structure.hasLicense = true;
53
- if (name === 'README.md' || name === 'readme.md') structure.hasReadme = true;
54
- if (name === '.env' || name === '.env.local') structure.hasEnv = true;
55
- if (name === '.gitignore') structure.hasGit = true;
56
- if (name === 'CLAUDE.md') structure.hasIdeConfigs.push('claude-code');
57
- if (name === 'GEMINI.md') structure.hasIdeConfigs.push('gemini-cli');
58
- if (name === 'AGENTS.md') structure.hasIdeConfigs.push('codex-cli');
59
- }
60
- }
61
-
62
- // Check for .git directory
63
- if (fs.existsSync(path.join(dir, '.git'))) structure.hasGit = true;
64
- } catch (e) {
65
- console.warn('autoconfig: Failed to analyze directory structure', e.message);
66
- }
67
-
68
- return structure;
69
- }
70
-
71
- function calculateHealth(structure) {
72
- const checks = [
73
- { name: 'Source code', pass: structure.hasSrc, weight: 2 },
74
- { name: 'Tests', pass: structure.hasTests, weight: 2 },
75
- { name: 'Documentation', pass: structure.hasDocs, weight: 1 },
76
- { name: 'CI/CD', pass: structure.hasCI, weight: 1 },
77
- { name: 'Git', pass: structure.hasGit, weight: 1 },
78
- { name: 'README', pass: structure.hasReadme, weight: 1 },
79
- { name: 'License', pass: structure.hasLicense, weight: 1 },
80
- { name: 'Docker', pass: structure.hasDocker, weight: 1 },
81
- ];
82
-
83
- const totalWeight = checks.reduce((sum, c) => sum + c.weight, 0);
84
- const score = checks.reduce((sum, c) => sum + (c.pass ? c.weight : 0), 0);
85
- const pct = Math.round((score / totalWeight) * 100);
86
-
87
- return { pct, checks };
88
- }
89
-
90
- function recommendPacks(stack, structure, health) {
91
- const packs = ['core', 'memory']; // Always
92
- const reasons = {
93
- core: 'Essential multi-role agents (Atlas, Forge, Sentinel, Nexus)',
94
- memory: 'Persistent brain for context continuity across sessions',
95
- };
96
-
97
- // Dev Studio — if no docs or complex project
98
- if (!structure.hasDocs || structure.directories.length > 5) {
99
- packs.push('dev-studio');
100
- reasons['dev-studio'] = !structure.hasDocs
101
- ? 'No docs/ found — Huldah (Tech Writer) will help document'
102
- : 'Complex project — full SDLC pipeline recommended';
103
- }
104
-
105
- // Shield — if CI/CD exists or Docker
106
- if (structure.hasCI || structure.hasDocker) {
107
- packs.push('shield');
108
- reasons.shield = 'CI/CD and/or Docker detected — GRC compliance agents recommended';
109
- }
110
-
111
- // SEO — if it looks like a web project
112
- if (stack.framework && ['Next.js', 'Nuxt', 'Angular', 'React', 'Vue.js', 'Svelte'].includes(stack.framework)) {
113
- packs.push('seo');
114
- reasons.seo = `${stack.framework} web app detected — SEO audit agents recommended`;
115
- }
116
-
117
- return { packs, reasons };
118
- }
119
-
120
- function generateRecommendations(stack, structure, health) {
121
- const recs = [];
122
-
123
- if (!structure.hasTests) {
124
- recs.push({ agent: 'Sentinel', action: 'set up a test framework and write initial tests', priority: 'high' });
125
- }
126
- if (!structure.hasDocs) {
127
- recs.push({ agent: 'Forge', action: 'document the project architecture and API', priority: 'medium' });
128
- }
129
- if (!structure.hasCI) {
130
- recs.push({ agent: 'Forge', action: 'set up CI/CD pipeline', priority: 'medium' });
131
- }
132
- if (health.pct < 60) {
133
- recs.push({ agent: 'Sentinel', action: 'review code quality and project health', priority: 'high' });
134
- }
135
-
136
- // Context-specific
137
- if (structure.hasSrc) {
138
- recs.push({ agent: 'Forge', action: 'continue developing the current module', priority: 'normal' });
139
- }
140
-
141
- // Memory
142
- recs.push({ agent: 'Zecher', action: 'consolidate session memory', priority: 'normal' });
143
-
144
- return recs;
145
- }
146
-
147
- function getProjectName(dir) {
148
- try {
149
- const pkgPath = path.join(dir, 'package.json');
150
- if (fs.existsSync(pkgPath)) {
151
- const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
152
- if (pkg.name) return pkg.name;
153
- }
154
- } catch (e) {
155
- console.warn('autoconfig: Failed to read package.json in getProjectName', e.message);
156
- }
157
- return path.basename(dir);
158
- }
159
-
160
- // ── New Project Wizard ──
161
-
162
- async function newProjectWizard() {
163
- const projectType = await clack.select({
164
- message: 'What type of project?',
165
- options: [
166
- { value: 'web', label: '🌐 Web Application', hint: 'SPA, SSR, static site' },
167
- { value: 'api', label: '⚡ API / Backend', hint: 'REST, GraphQL, microservices' },
168
- { value: 'cli', label: '💻 CLI Tool', hint: 'command-line application' },
169
- { value: 'mobile', label: '📱 Mobile App', hint: 'React Native, Flutter' },
170
- { value: 'library', label: '📦 Library / Package', hint: 'npm, PyPI, crate' },
171
- { value: 'other', label: '🔧 Other', hint: 'custom project' },
172
- ],
173
- });
174
-
175
- if (clack.isCancel(projectType)) return null;
176
-
177
- const description = await clack.text({
178
- message: 'Describe your project in one sentence:',
179
- placeholder: 'A billing SaaS for freelancers with Stripe integration',
180
- });
181
-
182
- if (clack.isCancel(description)) return null;
183
-
184
- return { type: projectType, description };
185
- }
186
-
187
- // ── Main Action ──
188
-
189
- module.exports = {
190
- command: 'autoconfig',
191
- description: 'Smart project bootstrap — auto-detect, install, and configure',
192
- options: [
193
- ['-d, --directory <path>', 'Project directory (default: current directory)'],
194
- ['-l, --lang <code>', 'Language code: en, fr, es, de, pt-br, ru, zh, he, ja, it'],
195
- ['-y, --yes', 'Accept all recommendations without prompting'],
196
- ],
197
- action: async (options) => {
198
- const projectDir = path.resolve(options.directory || process.cwd());
199
-
200
- clack.intro(pc.bgCyan(pc.black(' 🧠 BMAD+ Autoconfig ')));
201
-
202
- // Check if directory has content
203
- let entries = [];
204
- try { entries = fs.readdirSync(projectDir).filter(e => !e.startsWith('.')); } catch (e) { console.warn('autoconfig: Failed to list directory', e.message); }
205
-
206
- const isExistingProject = entries.length > 0;
207
-
208
- if (isExistingProject) {
209
- // ── MODE A: Existing Project ──
210
- clack.log.info(pc.bold(`📂 Existing project detected: ${getProjectName(projectDir)}`));
211
-
212
- const spinner = clack.spinner();
213
- spinner.start('Analyzing project...');
214
-
215
- const stack = detectStack(projectDir);
216
- const structure = analyzeStructure(projectDir);
217
- const health = calculateHealth(structure);
218
- const { packs, reasons } = recommendPacks(stack, structure, health);
219
- const recs = generateRecommendations(stack, structure, health);
220
-
221
- spinner.stop('Analysis complete');
222
-
223
- // Display analysis
224
- clack.log.info('');
225
- clack.log.info(pc.bold('📊 Project Analysis'));
226
- clack.log.info('');
227
-
228
- // Stack
229
- const stackLabel = [stack.framework, stack.language, stack.runtime].filter(Boolean).join(' + ') || 'Unknown';
230
- clack.log.info(` Stack: ${pc.cyan(stackLabel)}${stack.packageManager ? pc.dim(` (${stack.packageManager})`) : ''}`);
231
-
232
- // Structure
233
- const structItems = [];
234
- if (structure.hasSrc) structItems.push(pc.green('src/'));
235
- if (structure.hasTests) structItems.push(pc.green('tests/'));
236
- if (structure.hasDocs) structItems.push(pc.green('docs/'));
237
- if (structure.hasCI) structItems.push(pc.green('CI/CD'));
238
- if (structure.hasDocker) structItems.push(pc.green('Docker'));
239
- if (!structure.hasTests) structItems.push(pc.red('no tests'));
240
- if (!structure.hasDocs) structItems.push(pc.red('no docs'));
241
- clack.log.info(` Structure: ${structItems.join(' ')}`);
242
-
243
- // Health
244
- const healthColor = health.pct >= 80 ? pc.green : health.pct >= 50 ? pc.yellow : pc.red;
245
- const healthBar = '█'.repeat(Math.round(health.pct / 10)) + '░'.repeat(10 - Math.round(health.pct / 10));
246
- clack.log.info(` Health: ${healthColor(`${healthBar} ${health.pct}%`)}`);
247
-
248
- // Existing BMAD+
249
- if (structure.hasBmad) {
250
- clack.log.info(` BMAD+: ${pc.green('✓ already installed')} — will update`);
251
- }
252
- if (structure.hasIdeConfigs.length > 0) {
253
- clack.log.info(` IDE configs: ${pc.green('✓')} ${structure.hasIdeConfigs.length} found — will preserve`);
254
- }
255
-
256
- clack.log.info('');
257
-
258
- // Pack recommendations
259
- clack.log.info(pc.bold('📦 Recommended Packs'));
260
- clack.log.info('');
261
- for (const packId of packs) {
262
- clack.log.info(` ${pc.green('✓')} ${pc.bold(packId.padEnd(12))} ${pc.dim(reasons[packId])}`);
263
- }
264
- clack.log.info('');
265
-
266
- // Confirm
267
- if (!options.yes) {
268
- const answer = await clack.confirm({
269
- message: `Install ${packs.length} recommended packs?`,
270
- initialValue: true,
271
- });
272
- if (clack.isCancel(answer) || !answer) {
273
- clack.cancel('Autoconfig cancelled.');
274
- return;
275
- }
276
- }
277
-
278
- // Run install
279
- const spinner2 = clack.spinner();
280
- spinner2.start('Installing...');
281
-
282
- // Use the install module directly
283
- const installModule = require('./install');
284
-
285
- // NODE-06: only generate IDE configs for IDEs this project actually uses.
286
- // - If IDE config files already exist, preserve them ('none').
287
- // - Otherwise detect IDE markers and pass only those; never let install's
288
- // --yes fallback write ALL three configs into a project that uses none.
289
- let toolsArg;
290
- if (structure.hasIdeConfigs.length > 0) {
291
- toolsArg = 'none';
292
- } else {
293
- const detectedIDEs = [];
294
- for (const [id, ide] of Object.entries(IDE_CONFIGS)) {
295
- if (ide.detect.some(marker => fs.existsSync(path.join(projectDir, marker)))) {
296
- detectedIDEs.push(id);
297
- }
298
- }
299
- toolsArg = detectedIDEs.length > 0 ? detectedIDEs.join(',') : 'none';
300
- }
301
-
302
- // Build install args
303
- try {
304
- await installModule.action({
305
- directory: projectDir,
306
- packs: packs.join(','),
307
- yes: true,
308
- tools: toolsArg,
309
- lang: options.lang,
310
- });
311
- } catch (e) {
312
- clack.log.error(`Autoconfig install failed: ${e.message}`);
313
- throw e;
314
- }
315
-
316
- spinner2.stop('Installation complete');
317
-
318
- // Update memory context.md
319
- const contextPath = path.join(projectDir, '.agents', 'memory', 'context.md');
320
- if (fs.existsSync(path.dirname(contextPath))) {
321
- const contextContent = [
322
- '---',
323
- 'title: Project Context',
324
- `last_updated: "${new Date().toISOString().slice(0, 10)}"`,
325
- `auto_generated: true`,
326
- '---',
327
- '',
328
- '# Project Context',
329
- '',
330
- `> Auto-generated by \`npx bmad-plus autoconfig\` — ${new Date().toISOString().slice(0, 10)}`,
331
- '',
332
- '## Stack',
333
- '',
334
- `- **Language:** ${stack.language || 'Unknown'}`,
335
- `- **Framework:** ${stack.framework || 'None'}`,
336
- `- **Runtime:** ${stack.runtime || 'Unknown'}`,
337
- `- **Package Manager:** ${stack.packageManager || 'N/A'}`,
338
- `- **TypeScript:** ${stack.hasTypeScript ? 'Yes' : 'No'}`,
339
- '',
340
- '## Structure',
341
- '',
342
- `- **Source code:** ${structure.hasSrc ? 'Yes' : 'No'}`,
343
- `- **Tests:** ${structure.hasTests ? 'Yes' : 'No — needs setup'}`,
344
- `- **Documentation:** ${structure.hasDocs ? 'Yes' : 'No — needs writing'}`,
345
- `- **CI/CD:** ${structure.hasCI ? 'Yes' : 'No'}`,
346
- `- **Docker:** ${structure.hasDocker ? 'Yes' : 'No'}`,
347
- `- **Git:** ${structure.hasGit ? 'Yes' : 'No'}`,
348
- '',
349
- '## Health',
350
- '',
351
- `- **Score:** ${health.pct}%`,
352
- ...health.checks.map(c => `- ${c.pass ? '✅' : '❌'} ${c.name}`),
353
- '',
354
- '## Key Directories',
355
- '',
356
- ...structure.directories.slice(0, 15).map(d => `- \`${d}/\``),
357
- '',
358
- '## Installed Packs',
359
- '',
360
- ...packs.map(p => `- ${p}`),
361
- '',
362
- ];
363
-
364
- fs.writeFileSync(contextPath, contextContent.join('\n'), 'utf8');
365
- }
366
-
367
- // Display recommendations
368
- clack.log.info('');
369
- clack.log.info(pc.bold('🎯 Recommended Next Steps'));
370
- clack.log.info('');
371
-
372
- const priorityIcon = { high: pc.red('‼'), medium: pc.yellow('!'), normal: pc.dim('·') };
373
- for (const rec of recs.slice(0, 5)) {
374
- clack.log.info(` ${priorityIcon[rec.priority] || '·'} "${pc.cyan(rec.agent)}, ${rec.action}"`);
375
- }
376
-
377
- clack.log.info('');
378
-
379
- } else {
380
- // ── MODE B: New Project ──
381
- clack.log.info(pc.bold('🆕 Empty directory — starting new project wizard'));
382
- clack.log.info('');
383
-
384
- const wizard = await newProjectWizard();
385
- if (!wizard) {
386
- clack.cancel('Autoconfig cancelled.');
387
- return;
388
- }
389
-
390
- // Select packs based on project type
391
- const typePacks = {
392
- web: ['core', 'memory', 'dev-studio', 'seo'],
393
- api: ['core', 'memory', 'dev-studio', 'shield'],
394
- cli: ['core', 'memory'],
395
- mobile: ['core', 'memory', 'dev-studio'],
396
- library: ['core', 'memory', 'dev-studio'],
397
- other: ['core', 'memory'],
398
- };
399
-
400
- const packs = typePacks[wizard.type] || ['core', 'memory'];
401
-
402
- clack.log.info(`📦 Packs for ${wizard.type} project: ${packs.join(', ')}`);
403
-
404
- // Run install
405
- try {
406
- const installModule = require('./install');
407
- await installModule.action({
408
- directory: projectDir,
409
- packs: packs.join(','),
410
- yes: true,
411
- lang: options.lang,
412
- });
413
- } catch (e) {
414
- clack.log.error(`Autoconfig install failed: ${e.message}`);
415
- throw e;
416
- }
417
-
418
- // Write initial context
419
- const contextPath = path.join(projectDir, '.agents', 'memory', 'context.md');
420
- if (fs.existsSync(path.dirname(contextPath))) {
421
- const contextContent = [
422
- '---',
423
- 'title: Project Context',
424
- `last_updated: "${new Date().toISOString().slice(0, 10)}"`,
425
- `auto_generated: true`,
426
- '---',
427
- '',
428
- '# Project Context',
429
- '',
430
- `> Auto-generated by \`npx bmad-plus autoconfig\` — ${new Date().toISOString().slice(0, 10)}`,
431
- '',
432
- '## Project Brief',
433
- '',
434
- `- **Type:** ${wizard.type}`,
435
- `- **Description:** ${wizard.description}`,
436
- `- **Status:** New — not started`,
437
- '',
438
- '## Installed Packs',
439
- '',
440
- ...packs.map(p => `- ${p}`),
441
- '',
442
- ];
443
-
444
- fs.writeFileSync(contextPath, contextContent.join('\n'), 'utf8');
445
- }
446
-
447
- // Recommendations for new project
448
- clack.log.info('');
449
- clack.log.info(pc.bold('🎯 Recommended First Steps'));
450
- clack.log.info('');
451
- clack.log.info(` 1. "${pc.cyan('Atlas')}, I want to build: ${wizard.description}"`);
452
- clack.log.info(` 2. "${pc.cyan('Atlas')}, create the PRD"`);
453
- clack.log.info(` 3. "${pc.cyan('Forge')}, propose the architecture"`);
454
- clack.log.info(` 4. Or: "${pc.cyan('autopilot')}" to let Nexus manage everything`);
455
- clack.log.info('');
456
- }
457
-
458
- clack.outro(pc.green('Autoconfig complete! 🚀'));
459
- },
460
- // Exported for functional testing (not part of the public API)
461
- _internal: {
462
- detectStack,
463
- analyzeStructure,
464
- calculateHealth,
465
- recommendPacks,
466
- generateRecommendations,
467
- getProjectName,
468
- newProjectWizard,
469
- },
470
- };
1
+ /**
2
+ * BMAD+ Autoconfig Command
3
+ * Smart project bootstrap — analyzes existing projects or guides new ones.
4
+ * Auto-detects stack, selects best packs, installs, populates memory.
5
+ *
6
+ * Author: Laurent Rochetta
7
+ */
8
+
9
+ const path = require('node:path');
10
+ const fs = require('node:fs');
11
+ const clack = require('@clack/prompts');
12
+ const pc = require('picocolors');
13
+ const { detectStack } = require('../lib/stack-detect');
14
+ const { IDE_CONFIGS } = require('../lib/ide-config');
15
+
16
+ // ── Project Analysis Engine ──
17
+
18
+ function analyzeStructure(dir) {
19
+ const structure = {
20
+ hasSrc: false,
21
+ hasTests: false,
22
+ hasDocs: false,
23
+ hasCI: false,
24
+ hasDocker: false,
25
+ hasConfig: false,
26
+ hasLicense: false,
27
+ hasReadme: false,
28
+ hasGit: false,
29
+ hasEnv: false,
30
+ hasBmad: false,
31
+ hasIdeConfigs: [],
32
+ fileCount: 0,
33
+ directories: [],
34
+ };
35
+
36
+ try {
37
+ const entries = fs.readdirSync(dir, { withFileTypes: true });
38
+
39
+ for (const entry of entries) {
40
+ if (entry.isDirectory()) {
41
+ const name = entry.name.toLowerCase();
42
+ if (name === 'src' || name === 'lib' || name === 'app') structure.hasSrc = true;
43
+ if (name === 'tests' || name === 'test' || name === '__tests__' || name === 'spec') structure.hasTests = true;
44
+ if (name === 'docs' || name === 'doc' || name === 'documentation') structure.hasDocs = true;
45
+ if (name === '.github' || name === '.gitlab-ci' || name === '.circleci') structure.hasCI = true;
46
+ if (name === '.agents' || name === '_bmad') structure.hasBmad = true;
47
+ if (!name.startsWith('.') && name !== 'node_modules') structure.directories.push(entry.name);
48
+ } else {
49
+ structure.fileCount++;
50
+ const name = entry.name;
51
+ if (name === 'Dockerfile' || name === 'docker-compose.yml' || name === 'docker-compose.yaml') structure.hasDocker = true;
52
+ if (name === 'LICENSE' || name === 'LICENSE.md') structure.hasLicense = true;
53
+ if (name === 'README.md' || name === 'readme.md') structure.hasReadme = true;
54
+ if (name === '.env' || name === '.env.local') structure.hasEnv = true;
55
+ if (name === '.gitignore') structure.hasGit = true;
56
+ if (name === 'CLAUDE.md') structure.hasIdeConfigs.push('claude-code');
57
+ if (name === 'GEMINI.md') structure.hasIdeConfigs.push('gemini-cli');
58
+ if (name === 'AGENTS.md') structure.hasIdeConfigs.push('codex-cli');
59
+ }
60
+ }
61
+
62
+ // Check for .git directory
63
+ if (fs.existsSync(path.join(dir, '.git'))) structure.hasGit = true;
64
+ } catch (e) {
65
+ console.warn('autoconfig: Failed to analyze directory structure', e.message);
66
+ }
67
+
68
+ return structure;
69
+ }
70
+
71
+ function calculateHealth(structure) {
72
+ const checks = [
73
+ { name: 'Source code', pass: structure.hasSrc, weight: 2 },
74
+ { name: 'Tests', pass: structure.hasTests, weight: 2 },
75
+ { name: 'Documentation', pass: structure.hasDocs, weight: 1 },
76
+ { name: 'CI/CD', pass: structure.hasCI, weight: 1 },
77
+ { name: 'Git', pass: structure.hasGit, weight: 1 },
78
+ { name: 'README', pass: structure.hasReadme, weight: 1 },
79
+ { name: 'License', pass: structure.hasLicense, weight: 1 },
80
+ { name: 'Docker', pass: structure.hasDocker, weight: 1 },
81
+ ];
82
+
83
+ const totalWeight = checks.reduce((sum, c) => sum + c.weight, 0);
84
+ const score = checks.reduce((sum, c) => sum + (c.pass ? c.weight : 0), 0);
85
+ const pct = Math.round((score / totalWeight) * 100);
86
+
87
+ return { pct, checks };
88
+ }
89
+
90
+ function recommendPacks(stack, structure, health) {
91
+ const packs = ['core', 'memory']; // Always
92
+ const reasons = {
93
+ core: 'Essential multi-role agents (Atlas, Forge, Sentinel, Nexus)',
94
+ memory: 'Persistent brain for context continuity across sessions',
95
+ };
96
+
97
+ // Dev Studio — if no docs or complex project
98
+ if (!structure.hasDocs || structure.directories.length > 5) {
99
+ packs.push('dev-studio');
100
+ reasons['dev-studio'] = !structure.hasDocs
101
+ ? 'No docs/ found — Huldah (Tech Writer) will help document'
102
+ : 'Complex project — full SDLC pipeline recommended';
103
+ }
104
+
105
+ // Shield — if CI/CD exists or Docker
106
+ if (structure.hasCI || structure.hasDocker) {
107
+ packs.push('shield');
108
+ reasons.shield = 'CI/CD and/or Docker detected — GRC compliance agents recommended';
109
+ }
110
+
111
+ // SEO — if it looks like a web project
112
+ if (stack.framework && ['Next.js', 'Nuxt', 'Angular', 'React', 'Vue.js', 'Svelte'].includes(stack.framework)) {
113
+ packs.push('seo');
114
+ reasons.seo = `${stack.framework} web app detected — SEO audit agents recommended`;
115
+ }
116
+
117
+ return { packs, reasons };
118
+ }
119
+
120
+ function generateRecommendations(stack, structure, health) {
121
+ const recs = [];
122
+
123
+ if (!structure.hasTests) {
124
+ recs.push({ agent: 'Sentinel', action: 'set up a test framework and write initial tests', priority: 'high' });
125
+ }
126
+ if (!structure.hasDocs) {
127
+ recs.push({ agent: 'Forge', action: 'document the project architecture and API', priority: 'medium' });
128
+ }
129
+ if (!structure.hasCI) {
130
+ recs.push({ agent: 'Forge', action: 'set up CI/CD pipeline', priority: 'medium' });
131
+ }
132
+ if (health.pct < 60) {
133
+ recs.push({ agent: 'Sentinel', action: 'review code quality and project health', priority: 'high' });
134
+ }
135
+
136
+ // Context-specific
137
+ if (structure.hasSrc) {
138
+ recs.push({ agent: 'Forge', action: 'continue developing the current module', priority: 'normal' });
139
+ }
140
+
141
+ // Memory
142
+ recs.push({ agent: 'Zecher', action: 'consolidate session memory', priority: 'normal' });
143
+
144
+ return recs;
145
+ }
146
+
147
+ function getProjectName(dir) {
148
+ try {
149
+ const pkgPath = path.join(dir, 'package.json');
150
+ if (fs.existsSync(pkgPath)) {
151
+ const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
152
+ if (pkg.name) return pkg.name;
153
+ }
154
+ } catch (e) {
155
+ console.warn('autoconfig: Failed to read package.json in getProjectName', e.message);
156
+ }
157
+ return path.basename(dir);
158
+ }
159
+
160
+ // ── New Project Wizard ──
161
+
162
+ async function newProjectWizard() {
163
+ const projectType = await clack.select({
164
+ message: 'What type of project?',
165
+ options: [
166
+ { value: 'web', label: '🌐 Web Application', hint: 'SPA, SSR, static site' },
167
+ { value: 'api', label: '⚡ API / Backend', hint: 'REST, GraphQL, microservices' },
168
+ { value: 'cli', label: '💻 CLI Tool', hint: 'command-line application' },
169
+ { value: 'mobile', label: '📱 Mobile App', hint: 'React Native, Flutter' },
170
+ { value: 'library', label: '📦 Library / Package', hint: 'npm, PyPI, crate' },
171
+ { value: 'other', label: '🔧 Other', hint: 'custom project' },
172
+ ],
173
+ });
174
+
175
+ if (clack.isCancel(projectType)) return null;
176
+
177
+ const description = await clack.text({
178
+ message: 'Describe your project in one sentence:',
179
+ placeholder: 'A billing SaaS for freelancers with Stripe integration',
180
+ });
181
+
182
+ if (clack.isCancel(description)) return null;
183
+
184
+ return { type: projectType, description };
185
+ }
186
+
187
+ // ── Main Action ──
188
+
189
+ module.exports = {
190
+ command: 'autoconfig',
191
+ description: 'Smart project bootstrap — auto-detect, install, and configure',
192
+ options: [
193
+ ['-d, --directory <path>', 'Project directory (default: current directory)'],
194
+ ['-l, --lang <code>', 'Language code: en, fr, es, de, pt-br, ru, zh, he, ja, it'],
195
+ ['-y, --yes', 'Accept all recommendations without prompting'],
196
+ ],
197
+ action: async (options) => {
198
+ const projectDir = path.resolve(options.directory || process.cwd());
199
+
200
+ clack.intro(pc.bgCyan(pc.black(' 🧠 BMAD+ Autoconfig ')));
201
+
202
+ // Check if directory has content
203
+ let entries = [];
204
+ try { entries = fs.readdirSync(projectDir).filter(e => !e.startsWith('.')); } catch (e) { console.warn('autoconfig: Failed to list directory', e.message); }
205
+
206
+ const isExistingProject = entries.length > 0;
207
+
208
+ if (isExistingProject) {
209
+ // ── MODE A: Existing Project ──
210
+ clack.log.info(pc.bold(`📂 Existing project detected: ${getProjectName(projectDir)}`));
211
+
212
+ const spinner = clack.spinner();
213
+ spinner.start('Analyzing project...');
214
+
215
+ const stack = detectStack(projectDir);
216
+ const structure = analyzeStructure(projectDir);
217
+ const health = calculateHealth(structure);
218
+ const { packs, reasons } = recommendPacks(stack, structure, health);
219
+ const recs = generateRecommendations(stack, structure, health);
220
+
221
+ spinner.stop('Analysis complete');
222
+
223
+ // Display analysis
224
+ clack.log.info('');
225
+ clack.log.info(pc.bold('📊 Project Analysis'));
226
+ clack.log.info('');
227
+
228
+ // Stack
229
+ const stackLabel = [stack.framework, stack.language, stack.runtime].filter(Boolean).join(' + ') || 'Unknown';
230
+ clack.log.info(` Stack: ${pc.cyan(stackLabel)}${stack.packageManager ? pc.dim(` (${stack.packageManager})`) : ''}`);
231
+
232
+ // Structure
233
+ const structItems = [];
234
+ if (structure.hasSrc) structItems.push(pc.green('src/'));
235
+ if (structure.hasTests) structItems.push(pc.green('tests/'));
236
+ if (structure.hasDocs) structItems.push(pc.green('docs/'));
237
+ if (structure.hasCI) structItems.push(pc.green('CI/CD'));
238
+ if (structure.hasDocker) structItems.push(pc.green('Docker'));
239
+ if (!structure.hasTests) structItems.push(pc.red('no tests'));
240
+ if (!structure.hasDocs) structItems.push(pc.red('no docs'));
241
+ clack.log.info(` Structure: ${structItems.join(' ')}`);
242
+
243
+ // Health
244
+ const healthColor = health.pct >= 80 ? pc.green : health.pct >= 50 ? pc.yellow : pc.red;
245
+ const healthBar = '█'.repeat(Math.round(health.pct / 10)) + '░'.repeat(10 - Math.round(health.pct / 10));
246
+ clack.log.info(` Health: ${healthColor(`${healthBar} ${health.pct}%`)}`);
247
+
248
+ // Existing BMAD+
249
+ if (structure.hasBmad) {
250
+ clack.log.info(` BMAD+: ${pc.green('✓ already installed')} — will update`);
251
+ }
252
+ if (structure.hasIdeConfigs.length > 0) {
253
+ clack.log.info(` IDE configs: ${pc.green('✓')} ${structure.hasIdeConfigs.length} found — will preserve`);
254
+ }
255
+
256
+ clack.log.info('');
257
+
258
+ // Pack recommendations
259
+ clack.log.info(pc.bold('📦 Recommended Packs'));
260
+ clack.log.info('');
261
+ for (const packId of packs) {
262
+ clack.log.info(` ${pc.green('✓')} ${pc.bold(packId.padEnd(12))} ${pc.dim(reasons[packId])}`);
263
+ }
264
+ clack.log.info('');
265
+
266
+ // Confirm
267
+ if (!options.yes) {
268
+ const answer = await clack.confirm({
269
+ message: `Install ${packs.length} recommended packs?`,
270
+ initialValue: true,
271
+ });
272
+ if (clack.isCancel(answer) || !answer) {
273
+ clack.cancel('Autoconfig cancelled.');
274
+ return;
275
+ }
276
+ }
277
+
278
+ // Run install
279
+ const spinner2 = clack.spinner();
280
+ spinner2.start('Installing...');
281
+
282
+ // Use the install module directly
283
+ const installModule = require('./install');
284
+
285
+ // NODE-06: only generate IDE configs for IDEs this project actually uses.
286
+ // - If IDE config files already exist, preserve them ('none').
287
+ // - Otherwise detect IDE markers and pass only those; never let install's
288
+ // --yes fallback write ALL three configs into a project that uses none.
289
+ let toolsArg;
290
+ if (structure.hasIdeConfigs.length > 0) {
291
+ toolsArg = 'none';
292
+ } else {
293
+ const detectedIDEs = [];
294
+ for (const [id, ide] of Object.entries(IDE_CONFIGS)) {
295
+ if (ide.detect.some(marker => fs.existsSync(path.join(projectDir, marker)))) {
296
+ detectedIDEs.push(id);
297
+ }
298
+ }
299
+ toolsArg = detectedIDEs.length > 0 ? detectedIDEs.join(',') : 'none';
300
+ }
301
+
302
+ // Build install args
303
+ try {
304
+ await installModule.action({
305
+ directory: projectDir,
306
+ packs: packs.join(','),
307
+ yes: true,
308
+ tools: toolsArg,
309
+ lang: options.lang,
310
+ });
311
+ } catch (e) {
312
+ clack.log.error(`Autoconfig install failed: ${e.message}`);
313
+ throw e;
314
+ }
315
+
316
+ spinner2.stop('Installation complete');
317
+
318
+ // Update memory context.md
319
+ const contextPath = path.join(projectDir, '.agents', 'memory', 'context.md');
320
+ if (fs.existsSync(path.dirname(contextPath))) {
321
+ const contextContent = [
322
+ '---',
323
+ 'title: Project Context',
324
+ `last_updated: "${new Date().toISOString().slice(0, 10)}"`,
325
+ `auto_generated: true`,
326
+ '---',
327
+ '',
328
+ '# Project Context',
329
+ '',
330
+ `> Auto-generated by \`npx bmad-plus autoconfig\` — ${new Date().toISOString().slice(0, 10)}`,
331
+ '',
332
+ '## Stack',
333
+ '',
334
+ `- **Language:** ${stack.language || 'Unknown'}`,
335
+ `- **Framework:** ${stack.framework || 'None'}`,
336
+ `- **Runtime:** ${stack.runtime || 'Unknown'}`,
337
+ `- **Package Manager:** ${stack.packageManager || 'N/A'}`,
338
+ `- **TypeScript:** ${stack.hasTypeScript ? 'Yes' : 'No'}`,
339
+ '',
340
+ '## Structure',
341
+ '',
342
+ `- **Source code:** ${structure.hasSrc ? 'Yes' : 'No'}`,
343
+ `- **Tests:** ${structure.hasTests ? 'Yes' : 'No — needs setup'}`,
344
+ `- **Documentation:** ${structure.hasDocs ? 'Yes' : 'No — needs writing'}`,
345
+ `- **CI/CD:** ${structure.hasCI ? 'Yes' : 'No'}`,
346
+ `- **Docker:** ${structure.hasDocker ? 'Yes' : 'No'}`,
347
+ `- **Git:** ${structure.hasGit ? 'Yes' : 'No'}`,
348
+ '',
349
+ '## Health',
350
+ '',
351
+ `- **Score:** ${health.pct}%`,
352
+ ...health.checks.map(c => `- ${c.pass ? '✅' : '❌'} ${c.name}`),
353
+ '',
354
+ '## Key Directories',
355
+ '',
356
+ ...structure.directories.slice(0, 15).map(d => `- \`${d}/\``),
357
+ '',
358
+ '## Installed Packs',
359
+ '',
360
+ ...packs.map(p => `- ${p}`),
361
+ '',
362
+ ];
363
+
364
+ fs.writeFileSync(contextPath, contextContent.join('\n'), 'utf8');
365
+ }
366
+
367
+ // Display recommendations
368
+ clack.log.info('');
369
+ clack.log.info(pc.bold('🎯 Recommended Next Steps'));
370
+ clack.log.info('');
371
+
372
+ const priorityIcon = { high: pc.red('‼'), medium: pc.yellow('!'), normal: pc.dim('·') };
373
+ for (const rec of recs.slice(0, 5)) {
374
+ clack.log.info(` ${priorityIcon[rec.priority] || '·'} "${pc.cyan(rec.agent)}, ${rec.action}"`);
375
+ }
376
+
377
+ clack.log.info('');
378
+
379
+ } else {
380
+ // ── MODE B: New Project ──
381
+ clack.log.info(pc.bold('🆕 Empty directory — starting new project wizard'));
382
+ clack.log.info('');
383
+
384
+ const wizard = await newProjectWizard();
385
+ if (!wizard) {
386
+ clack.cancel('Autoconfig cancelled.');
387
+ return;
388
+ }
389
+
390
+ // Select packs based on project type
391
+ const typePacks = {
392
+ web: ['core', 'memory', 'dev-studio', 'seo'],
393
+ api: ['core', 'memory', 'dev-studio', 'shield'],
394
+ cli: ['core', 'memory'],
395
+ mobile: ['core', 'memory', 'dev-studio'],
396
+ library: ['core', 'memory', 'dev-studio'],
397
+ other: ['core', 'memory'],
398
+ };
399
+
400
+ const packs = typePacks[wizard.type] || ['core', 'memory'];
401
+
402
+ clack.log.info(`📦 Packs for ${wizard.type} project: ${packs.join(', ')}`);
403
+
404
+ // Run install
405
+ try {
406
+ const installModule = require('./install');
407
+ await installModule.action({
408
+ directory: projectDir,
409
+ packs: packs.join(','),
410
+ yes: true,
411
+ lang: options.lang,
412
+ });
413
+ } catch (e) {
414
+ clack.log.error(`Autoconfig install failed: ${e.message}`);
415
+ throw e;
416
+ }
417
+
418
+ // Write initial context
419
+ const contextPath = path.join(projectDir, '.agents', 'memory', 'context.md');
420
+ if (fs.existsSync(path.dirname(contextPath))) {
421
+ const contextContent = [
422
+ '---',
423
+ 'title: Project Context',
424
+ `last_updated: "${new Date().toISOString().slice(0, 10)}"`,
425
+ `auto_generated: true`,
426
+ '---',
427
+ '',
428
+ '# Project Context',
429
+ '',
430
+ `> Auto-generated by \`npx bmad-plus autoconfig\` — ${new Date().toISOString().slice(0, 10)}`,
431
+ '',
432
+ '## Project Brief',
433
+ '',
434
+ `- **Type:** ${wizard.type}`,
435
+ `- **Description:** ${wizard.description}`,
436
+ `- **Status:** New — not started`,
437
+ '',
438
+ '## Installed Packs',
439
+ '',
440
+ ...packs.map(p => `- ${p}`),
441
+ '',
442
+ ];
443
+
444
+ fs.writeFileSync(contextPath, contextContent.join('\n'), 'utf8');
445
+ }
446
+
447
+ // Recommendations for new project
448
+ clack.log.info('');
449
+ clack.log.info(pc.bold('🎯 Recommended First Steps'));
450
+ clack.log.info('');
451
+ clack.log.info(` 1. "${pc.cyan('Atlas')}, I want to build: ${wizard.description}"`);
452
+ clack.log.info(` 2. "${pc.cyan('Atlas')}, create the PRD"`);
453
+ clack.log.info(` 3. "${pc.cyan('Forge')}, propose the architecture"`);
454
+ clack.log.info(` 4. Or: "${pc.cyan('autopilot')}" to let Nexus manage everything`);
455
+ clack.log.info('');
456
+ }
457
+
458
+ clack.outro(pc.green('Autoconfig complete! 🚀'));
459
+ },
460
+ // Exported for functional testing (not part of the public API)
461
+ _internal: {
462
+ detectStack,
463
+ analyzeStructure,
464
+ calculateHealth,
465
+ recommendPacks,
466
+ generateRecommendations,
467
+ getProjectName,
468
+ newProjectWizard,
469
+ },
470
+ };