From 4d0b0fdcd12e87b954b3ab5f8670dae88b3325f5 Mon Sep 17 00:00:00 2001 From: nick Date: Fri, 1 May 2026 15:36:50 +0800 Subject: [PATCH] feat(installer): add badge prompt and auto-create README if missing - Interactive prompt asks "Add BMAD badge to your README?" (default yes) - --no-badge skips the prompt and disables badge - --yes accepts badge by default - If user wants badge but no README exists, creates README.md with project name and badge Generated with [Claude Code](https://claude.ai/code) via [Happy](https://happy.engineering) Co-Authored-By: Claude Co-Authored-By: Happy --- tools/installer/commands/install.js | 13 ++++++++++++- tools/installer/core/badge.js | 6 ++++++ tools/installer/core/installer.js | 7 ++++++- 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/tools/installer/commands/install.js b/tools/installer/commands/install.js index 61598a2cf..4df7981ed 100644 --- a/tools/installer/commands/install.js +++ b/tools/installer/commands/install.js @@ -96,7 +96,18 @@ module.exports = { } const config = await ui.promptInstall(options); - config.noBadge = options.badge === false; + + // Ask about badge unless --no-badge or --yes + if (options.badge === false) { + config.noBadge = true; + } else if (options.yes) { + config.noBadge = false; + } else { + config.noBadge = !(await prompts.confirm({ + message: 'Add BMAD badge to your README?', + default: true, + })); + } // Handle cancel if (config.actionType === 'cancel') { diff --git a/tools/installer/core/badge.js b/tools/installer/core/badge.js index 7623c256b..0a9b250f5 100644 --- a/tools/installer/core/badge.js +++ b/tools/installer/core/badge.js @@ -73,6 +73,11 @@ function removeBadge(content) { .join('\n'); } +function createReadmeWithBadge(owner, repo, projectName) { + const badgeLine = generateBadgeMarkdown(owner, repo); + return `# ${projectName}\n\n${badgeLine}\n`; +} + module.exports = { resolveGitRemote, findReadme, @@ -80,4 +85,5 @@ module.exports = { generateBadgeMarkdown, injectBadge, removeBadge, + createReadmeWithBadge, }; diff --git a/tools/installer/core/installer.js b/tools/installer/core/installer.js index b6c2d8e52..580ecb57d 100644 --- a/tools/installer/core/installer.js +++ b/tools/installer/core/installer.js @@ -1061,7 +1061,12 @@ class Installer { const readmePath = await badge.findReadme(projectDir); if (!readmePath) { - addResult('Badge', 'warn', 'no README found'); + // No README — create one with the badge + const projectName = path.basename(projectDir); + const content = badge.createReadmeWithBadge(remote.owner, remote.repo, projectName); + const newReadmePath = path.join(projectDir, 'README.md'); + await fs.writeFile(newReadmePath, content, 'utf8'); + addResult('Badge', 'ok', 'created README.md with badge'); return; }