Compare commits
1 Commits
a1a704494c
...
7b3e75603b
| Author | SHA1 | Date |
|---|---|---|
|
|
7b3e75603b |
|
|
@ -78,6 +78,7 @@ your-project/
|
||||||
├── _bmad/ # BMad configuration
|
├── _bmad/ # BMad configuration
|
||||||
├── _bmad-output/
|
├── _bmad-output/
|
||||||
│ ├── PRD.md # Your requirements document
|
│ ├── PRD.md # Your requirements document
|
||||||
|
│ └── bmm-workflow-status.yaml # Progress tracking
|
||||||
└── ...
|
└── ...
|
||||||
```
|
```
|
||||||
````
|
````
|
||||||
|
|
@ -141,12 +142,12 @@ your-project/
|
||||||
|
|
||||||
### Types
|
### Types
|
||||||
|
|
||||||
| Type | Example |
|
| Type | Example |
|
||||||
| ----------------- | ----------------------------- |
|
| ----------------- | ---------------------------- |
|
||||||
| **Index/Landing** | `core-concepts/index.md` |
|
| **Index/Landing** | `core-concepts/index.md` |
|
||||||
| **Concept** | `what-are-agents.md` |
|
| **Concept** | `what-are-agents.md` |
|
||||||
| **Feature** | `quick-flow.md` |
|
| **Feature** | `quick-flow.md` |
|
||||||
| **Philosophy** | `why-solutioning-matters.md` |
|
| **Philosophy** | `why-solutioning-matters.md` |
|
||||||
| **FAQ** | `established-projects-faq.md` |
|
| **FAQ** | `established-projects-faq.md` |
|
||||||
|
|
||||||
### General Template
|
### General Template
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,6 @@
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"bmad:install": "node tools/cli/bmad-cli.js install",
|
"bmad:install": "node tools/cli/bmad-cli.js install",
|
||||||
"bmad:uninstall": "node tools/cli/bmad-cli.js uninstall",
|
|
||||||
"docs:build": "node tools/build-docs.mjs",
|
"docs:build": "node tools/build-docs.mjs",
|
||||||
"docs:dev": "astro dev --root website",
|
"docs:dev": "astro dev --root website",
|
||||||
"docs:fix-links": "node tools/fix-doc-links.js",
|
"docs:fix-links": "node tools/fix-doc-links.js",
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,55 @@
|
||||||
|
|
||||||
<critical>This router determines workflow mode and delegates to specialized sub-workflows</critical>
|
<critical>This router determines workflow mode and delegates to specialized sub-workflows</critical>
|
||||||
|
|
||||||
<step n="1" goal="Check for ability to resume and determine workflow mode">
|
<step n="1" goal="Validate workflow and get project info">
|
||||||
|
|
||||||
|
<invoke-workflow path="{project-root}/_bmad/bmm/workflows/workflow-status">
|
||||||
|
<param>mode: data</param>
|
||||||
|
<param>data_request: project_config</param>
|
||||||
|
</invoke-workflow>
|
||||||
|
|
||||||
|
<check if="status_exists == false">
|
||||||
|
<output>{{suggestion}}</output>
|
||||||
|
<output>Note: Documentation workflow can run standalone. Continuing without progress tracking.</output>
|
||||||
|
<action>Set standalone_mode = true</action>
|
||||||
|
<action>Set status_file_found = false</action>
|
||||||
|
</check>
|
||||||
|
|
||||||
|
<check if="status_exists == true">
|
||||||
|
<action>Store {{status_file_path}} for later updates</action>
|
||||||
|
<action>Set status_file_found = true</action>
|
||||||
|
|
||||||
|
<!-- Extract brownfield/greenfield from status data -->
|
||||||
|
<check if="field_type == 'greenfield'">
|
||||||
|
<output>Note: This is a greenfield project. Documentation workflow is typically for brownfield projects.</output>
|
||||||
|
<ask>Continue anyway to document planning artifacts? (y/n)</ask>
|
||||||
|
<check if="n">
|
||||||
|
<action>Exit workflow</action>
|
||||||
|
</check>
|
||||||
|
</check>
|
||||||
|
|
||||||
|
<!-- Now validate sequencing -->
|
||||||
|
<invoke-workflow path="{project-root}/_bmad/bmm/workflows/workflow-status">
|
||||||
|
<param>mode: validate</param>
|
||||||
|
<param>calling_workflow: document-project</param>
|
||||||
|
</invoke-workflow>
|
||||||
|
|
||||||
|
<check if="warning != ''">
|
||||||
|
<output>{{warning}}</output>
|
||||||
|
<output>Note: This may be auto-invoked by prd for brownfield documentation.</output>
|
||||||
|
<ask>Continue with documentation? (y/n)</ask>
|
||||||
|
<check if="n">
|
||||||
|
<output>{{suggestion}}</output>
|
||||||
|
<action>Exit workflow</action>
|
||||||
|
</check>
|
||||||
|
</check>
|
||||||
|
</check>
|
||||||
|
|
||||||
|
</step>
|
||||||
|
|
||||||
|
<step n="2" goal="Check for resumability and determine workflow mode">
|
||||||
|
<critical>SMART LOADING STRATEGY: Check state file FIRST before loading any CSV files</critical>
|
||||||
|
|
||||||
<action>Check for existing state file at: {project_knowledge}/project-scan-report.json</action>
|
<action>Check for existing state file at: {project_knowledge}/project-scan-report.json</action>
|
||||||
|
|
||||||
<check if="project-scan-report.json exists">
|
<check if="project-scan-report.json exists">
|
||||||
|
|
@ -18,21 +66,21 @@
|
||||||
|
|
||||||
<ask>I found an in-progress workflow state from {{last_updated}}.
|
<ask>I found an in-progress workflow state from {{last_updated}}.
|
||||||
|
|
||||||
**Current Progress:**
|
**Current Progress:**
|
||||||
|
|
||||||
- Mode: {{mode}}
|
- Mode: {{mode}}
|
||||||
- Scan Level: {{scan_level}}
|
- Scan Level: {{scan_level}}
|
||||||
- Completed Steps: {{completed_steps_count}}/{{total_steps}}
|
- Completed Steps: {{completed_steps_count}}/{{total_steps}}
|
||||||
- Last Step: {{current_step}}
|
- Last Step: {{current_step}}
|
||||||
- Project Type(s): {{cached_project_types}}
|
- Project Type(s): {{cached_project_types}}
|
||||||
|
|
||||||
Would you like to:
|
Would you like to:
|
||||||
|
|
||||||
1. **Resume from where we left off** - Continue from step {{current_step}}
|
1. **Resume from where we left off** - Continue from step {{current_step}}
|
||||||
2. **Start fresh** - Archive old state and begin new scan
|
2. **Start fresh** - Archive old state and begin new scan
|
||||||
3. **Cancel** - Exit without changes
|
3. **Cancel** - Exit without changes
|
||||||
|
|
||||||
Your choice [1/2/3]:
|
Your choice [1/2/3]:
|
||||||
</ask>
|
</ask>
|
||||||
|
|
||||||
<check if="user selects 1">
|
<check if="user selects 1">
|
||||||
|
|
@ -127,4 +175,47 @@ Your choice [1/2/3]:
|
||||||
|
|
||||||
</step>
|
</step>
|
||||||
|
|
||||||
|
<step n="4" goal="Update status and complete">
|
||||||
|
|
||||||
|
<check if="status_file_found == true">
|
||||||
|
<invoke-workflow path="{project-root}/_bmad/bmm/workflows/workflow-status">
|
||||||
|
<param>mode: update</param>
|
||||||
|
<param>action: complete_workflow</param>
|
||||||
|
<param>workflow_name: document-project</param>
|
||||||
|
</invoke-workflow>
|
||||||
|
|
||||||
|
<check if="success == true">
|
||||||
|
<output>Status updated!</output>
|
||||||
|
</check>
|
||||||
|
</check>
|
||||||
|
|
||||||
|
<output>**✅ Document Project Workflow Complete, {user_name}!**
|
||||||
|
|
||||||
|
**Documentation Generated:**
|
||||||
|
|
||||||
|
- Mode: {{workflow_mode}}
|
||||||
|
- Scan Level: {{scan_level}}
|
||||||
|
- Output: {project_knowledge}/index.md and related files
|
||||||
|
|
||||||
|
{{#if status_file_found}}
|
||||||
|
**Status Updated:**
|
||||||
|
|
||||||
|
- Progress tracking updated
|
||||||
|
|
||||||
|
**Next Steps:**
|
||||||
|
|
||||||
|
- **Next required:** {{next_workflow}} ({{next_agent}} agent)
|
||||||
|
|
||||||
|
Check status anytime with: `workflow-status`
|
||||||
|
{{else}}
|
||||||
|
**Next Steps:**
|
||||||
|
Since no workflow is in progress:
|
||||||
|
|
||||||
|
- Refer to the BMM workflow guide if unsure what to do next
|
||||||
|
- Or run `workflow-init` to create a workflow path and get guided next steps
|
||||||
|
{{/if}}
|
||||||
|
</output>
|
||||||
|
|
||||||
|
</step>
|
||||||
|
|
||||||
</workflow>
|
</workflow>
|
||||||
|
|
|
||||||
|
|
@ -5,56 +5,3 @@
|
||||||
For external official modules to be discoverable during install, ensure an entry for the external repo is added to external-official-modules.yaml.
|
For external official modules to be discoverable during install, ensure an entry for the external repo is added to external-official-modules.yaml.
|
||||||
|
|
||||||
For community modules - this will be handled in a different way. This file is only for registration of modules under the bmad-code-org.
|
For community modules - this will be handled in a different way. This file is only for registration of modules under the bmad-code-org.
|
||||||
|
|
||||||
## Post-Install Notes
|
|
||||||
|
|
||||||
Modules can display setup guidance to users after configuration is collected during `npx bmad-method install`. Notes are defined in the module's own `module.yaml` — no changes to the installer are needed.
|
|
||||||
|
|
||||||
### Simple Format
|
|
||||||
|
|
||||||
Always displayed after the module is configured:
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
post-install-notes: |
|
|
||||||
Thank you for choosing the XYZ Cool Module
|
|
||||||
For Support about this Module call 555-1212
|
|
||||||
```
|
|
||||||
|
|
||||||
### Conditional Format
|
|
||||||
|
|
||||||
Display different messages based on a config question's answer:
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
post-install-notes:
|
|
||||||
config_key_name:
|
|
||||||
value1: |
|
|
||||||
Instructions for value1...
|
|
||||||
value2: |
|
|
||||||
Instructions for value2...
|
|
||||||
```
|
|
||||||
|
|
||||||
Values without an entry (e.g., `none`) display nothing. Multiple config keys can each have their own conditional notes.
|
|
||||||
|
|
||||||
### Example: TEA Module
|
|
||||||
|
|
||||||
The TEA module uses the conditional format keyed on `tea_browser_automation`:
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
post-install-notes:
|
|
||||||
tea_browser_automation:
|
|
||||||
cli: |
|
|
||||||
Playwright CLI Setup:
|
|
||||||
npm install -g @playwright/cli@latest
|
|
||||||
playwright-cli install --skills
|
|
||||||
mcp: |
|
|
||||||
Playwright MCP Setup (two servers):
|
|
||||||
1. playwright — npx @playwright/mcp@latest
|
|
||||||
2. playwright-test — npx playwright run-test-mcp-server
|
|
||||||
auto: |
|
|
||||||
Playwright CLI Setup:
|
|
||||||
...
|
|
||||||
Playwright MCP Setup (two servers):
|
|
||||||
...
|
|
||||||
```
|
|
||||||
|
|
||||||
When a user selects `auto`, they see both CLI and MCP instructions. When they select `none`, nothing is shown.
|
|
||||||
|
|
|
||||||
|
|
@ -1,167 +0,0 @@
|
||||||
const path = require('node:path');
|
|
||||||
const fs = require('fs-extra');
|
|
||||||
const prompts = require('../lib/prompts');
|
|
||||||
const { Installer } = require('../installers/lib/core/installer');
|
|
||||||
|
|
||||||
const installer = new Installer();
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
command: 'uninstall',
|
|
||||||
description: 'Remove BMAD installation from the current project',
|
|
||||||
options: [
|
|
||||||
['-y, --yes', 'Remove all BMAD components without prompting (preserves user artifacts)'],
|
|
||||||
['--directory <path>', 'Project directory (default: current directory)'],
|
|
||||||
],
|
|
||||||
action: async (options) => {
|
|
||||||
try {
|
|
||||||
let projectDir;
|
|
||||||
|
|
||||||
if (options.directory) {
|
|
||||||
// Explicit --directory flag takes precedence
|
|
||||||
projectDir = path.resolve(options.directory);
|
|
||||||
} else if (options.yes) {
|
|
||||||
// Non-interactive mode: use current directory
|
|
||||||
projectDir = process.cwd();
|
|
||||||
} else {
|
|
||||||
// Interactive: ask user which directory to uninstall from
|
|
||||||
// select() handles cancellation internally (exits process)
|
|
||||||
const dirChoice = await prompts.select({
|
|
||||||
message: 'Where do you want to uninstall BMAD from?',
|
|
||||||
choices: [
|
|
||||||
{ value: 'cwd', name: `Current directory (${process.cwd()})` },
|
|
||||||
{ value: 'other', name: 'Another directory...' },
|
|
||||||
],
|
|
||||||
});
|
|
||||||
|
|
||||||
if (dirChoice === 'other') {
|
|
||||||
// text() handles cancellation internally (exits process)
|
|
||||||
const customDir = await prompts.text({
|
|
||||||
message: 'Enter the project directory path:',
|
|
||||||
placeholder: process.cwd(),
|
|
||||||
validate: (value) => {
|
|
||||||
if (!value || value.trim().length === 0) return 'Directory path is required';
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
projectDir = path.resolve(customDir.trim());
|
|
||||||
} else {
|
|
||||||
projectDir = process.cwd();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(await fs.pathExists(projectDir))) {
|
|
||||||
await prompts.log.error(`Directory does not exist: ${projectDir}`);
|
|
||||||
process.exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
const { bmadDir } = await installer.findBmadDir(projectDir);
|
|
||||||
|
|
||||||
if (!(await fs.pathExists(bmadDir))) {
|
|
||||||
await prompts.log.warn('No BMAD installation found.');
|
|
||||||
process.exit(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
const existingInstall = await installer.getStatus(projectDir);
|
|
||||||
const version = existingInstall.version || 'unknown';
|
|
||||||
const modules = (existingInstall.modules || []).map((m) => m.id || m.name).join(', ');
|
|
||||||
const ides = (existingInstall.ides || []).join(', ');
|
|
||||||
|
|
||||||
const outputFolder = await installer.getOutputFolder(projectDir);
|
|
||||||
|
|
||||||
await prompts.intro('BMAD Uninstall');
|
|
||||||
await prompts.note(`Version: ${version}\nModules: ${modules}\nIDE integrations: ${ides}`, 'Current Installation');
|
|
||||||
|
|
||||||
let removeModules = true;
|
|
||||||
let removeIdeConfigs = true;
|
|
||||||
let removeOutputFolder = false;
|
|
||||||
|
|
||||||
if (!options.yes) {
|
|
||||||
// multiselect() handles cancellation internally (exits process)
|
|
||||||
const selected = await prompts.multiselect({
|
|
||||||
message: 'Select components to remove:',
|
|
||||||
options: [
|
|
||||||
{
|
|
||||||
value: 'modules',
|
|
||||||
label: `BMAD Modules & data (${installer.bmadFolderName}/)`,
|
|
||||||
hint: 'Core installation, agents, workflows, config',
|
|
||||||
},
|
|
||||||
{ value: 'ide', label: 'IDE integrations', hint: ides || 'No IDEs configured' },
|
|
||||||
{ value: 'output', label: `User artifacts (${outputFolder}/)`, hint: 'WARNING: Contains your work products' },
|
|
||||||
],
|
|
||||||
initialValues: ['modules', 'ide'],
|
|
||||||
required: true,
|
|
||||||
});
|
|
||||||
|
|
||||||
removeModules = selected.includes('modules');
|
|
||||||
removeIdeConfigs = selected.includes('ide');
|
|
||||||
removeOutputFolder = selected.includes('output');
|
|
||||||
|
|
||||||
const red = (s) => `\u001B[31m${s}\u001B[0m`;
|
|
||||||
await prompts.note(
|
|
||||||
red('💀 This action is IRREVERSIBLE! Removed files cannot be recovered!') +
|
|
||||||
'\n' +
|
|
||||||
red('💀 IDE configurations and modules will need to be reinstalled.') +
|
|
||||||
'\n' +
|
|
||||||
red('💀 User artifacts are preserved unless explicitly selected.'),
|
|
||||||
'!! DESTRUCTIVE ACTION !!',
|
|
||||||
);
|
|
||||||
|
|
||||||
const confirmed = await prompts.confirm({
|
|
||||||
message: 'Proceed with uninstall?',
|
|
||||||
default: false,
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!confirmed) {
|
|
||||||
await prompts.outro('Uninstall cancelled.');
|
|
||||||
process.exit(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Phase 1: IDE integrations
|
|
||||||
if (removeIdeConfigs) {
|
|
||||||
const s = await prompts.spinner();
|
|
||||||
s.start('Removing IDE integrations...');
|
|
||||||
await installer.uninstallIdeConfigs(projectDir, existingInstall, { silent: true });
|
|
||||||
s.stop(`Removed IDE integrations (${ides || 'none'})`);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Phase 2: User artifacts
|
|
||||||
if (removeOutputFolder) {
|
|
||||||
const s = await prompts.spinner();
|
|
||||||
s.start(`Removing user artifacts (${outputFolder}/)...`);
|
|
||||||
await installer.uninstallOutputFolder(projectDir, outputFolder);
|
|
||||||
s.stop('User artifacts removed');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Phase 3: BMAD modules & data (last — other phases may need _bmad/)
|
|
||||||
if (removeModules) {
|
|
||||||
const s = await prompts.spinner();
|
|
||||||
s.start(`Removing BMAD modules & data (${installer.bmadFolderName}/)...`);
|
|
||||||
await installer.uninstallModules(projectDir);
|
|
||||||
s.stop('Modules & data removed');
|
|
||||||
}
|
|
||||||
|
|
||||||
const summary = [];
|
|
||||||
if (removeIdeConfigs) summary.push('IDE integrations cleaned');
|
|
||||||
if (removeModules) summary.push('Modules & data removed');
|
|
||||||
if (removeOutputFolder) summary.push('User artifacts removed');
|
|
||||||
if (!removeOutputFolder) summary.push(`User artifacts preserved in ${outputFolder}/`);
|
|
||||||
|
|
||||||
await prompts.note(summary.join('\n'), 'Summary');
|
|
||||||
await prompts.outro('To reinstall, run: npx bmad-method install');
|
|
||||||
|
|
||||||
process.exit(0);
|
|
||||||
} catch (error) {
|
|
||||||
try {
|
|
||||||
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
||||||
await prompts.log.error(`Uninstall failed: ${errorMessage}`);
|
|
||||||
if (error instanceof Error && error.stack) {
|
|
||||||
await prompts.log.message(error.stack);
|
|
||||||
}
|
|
||||||
} catch {
|
|
||||||
console.error(error instanceof Error ? error.message : error);
|
|
||||||
}
|
|
||||||
process.exit(1);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
@ -34,7 +34,7 @@ startMessage: |
|
||||||
- Subscribe on YouTube: https://www.youtube.com/@BMadCode
|
- Subscribe on YouTube: https://www.youtube.com/@BMadCode
|
||||||
- Every star & sub helps us reach more developers!
|
- Every star & sub helps us reach more developers!
|
||||||
|
|
||||||
Latest updates: https://github.com/bmad-code-org/BMAD-METHOD/blob/main/CHANGELOG.md
|
Latest updates: https://github.com/bmad-code-org/BMAD-METHOD/CHANGELOG.md
|
||||||
|
|
||||||
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -302,30 +302,23 @@ class ConfigCollector {
|
||||||
|
|
||||||
const configSpinner = await prompts.spinner();
|
const configSpinner = await prompts.spinner();
|
||||||
configSpinner.start('Configuring modules...');
|
configSpinner.start('Configuring modules...');
|
||||||
try {
|
for (const moduleName of defaultModules) {
|
||||||
for (const moduleName of defaultModules) {
|
const displayName = displayNameMap.get(moduleName) || moduleName.toUpperCase();
|
||||||
const displayName = displayNameMap.get(moduleName) || moduleName.toUpperCase();
|
configSpinner.message(`Configuring ${displayName}...`);
|
||||||
configSpinner.message(`Configuring ${displayName}...`);
|
try {
|
||||||
try {
|
this._silentConfig = true;
|
||||||
this._silentConfig = true;
|
await this.collectModuleConfig(moduleName, projectDir);
|
||||||
await this.collectModuleConfig(moduleName, projectDir);
|
} finally {
|
||||||
} finally {
|
this._silentConfig = false;
|
||||||
this._silentConfig = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} finally {
|
|
||||||
configSpinner.stop(customizeModules.length > 0 ? 'Module defaults applied' : 'Module configuration complete');
|
|
||||||
}
|
}
|
||||||
|
configSpinner.stop('Module configuration complete');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run customized modules individually (may show interactive prompts)
|
// Run customized modules individually (may show interactive prompts)
|
||||||
for (const moduleName of customizeModules) {
|
for (const moduleName of customizeModules) {
|
||||||
await this.collectModuleConfig(moduleName, projectDir);
|
await this.collectModuleConfig(moduleName, projectDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (customizeModules.length > 0) {
|
|
||||||
await prompts.log.step('Module configuration complete');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add metadata
|
// Add metadata
|
||||||
|
|
@ -557,8 +550,6 @@ class ConfigCollector {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.displayModulePostConfigNotes(moduleName, moduleConfig);
|
|
||||||
|
|
||||||
return newKeys.length > 0 || newStaticKeys.length > 0; // Return true if we had any new fields (interactive or static)
|
return newKeys.length > 0 || newStaticKeys.length > 0; // Return true if we had any new fields (interactive or static)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -932,8 +923,6 @@ class ConfigCollector {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.displayModulePostConfigNotes(moduleName, moduleConfig);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -1206,58 +1195,6 @@ class ConfigCollector {
|
||||||
return question;
|
return question;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Display post-configuration notes for a module
|
|
||||||
* Shows prerequisite guidance based on collected config values
|
|
||||||
* Reads notes from the module's `post-install-notes` section in module.yaml
|
|
||||||
* Supports two formats:
|
|
||||||
* - Simple string: always displayed
|
|
||||||
* - Object keyed by config field name, with value-specific messages
|
|
||||||
* @param {string} moduleName - Module name
|
|
||||||
* @param {Object} moduleConfig - Parsed module.yaml content
|
|
||||||
*/
|
|
||||||
async displayModulePostConfigNotes(moduleName, moduleConfig) {
|
|
||||||
if (this._silentConfig) return;
|
|
||||||
if (!moduleConfig || !moduleConfig['post-install-notes']) return;
|
|
||||||
|
|
||||||
const notes = moduleConfig['post-install-notes'];
|
|
||||||
const color = await prompts.getColor();
|
|
||||||
|
|
||||||
// Format 1: Simple string - always display
|
|
||||||
if (typeof notes === 'string') {
|
|
||||||
await prompts.log.message('');
|
|
||||||
for (const line of notes.trim().split('\n')) {
|
|
||||||
await prompts.log.message(color.dim(line));
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Format 2: Conditional on config values
|
|
||||||
if (typeof notes === 'object') {
|
|
||||||
const config = this.collectedConfig[moduleName];
|
|
||||||
if (!config) return;
|
|
||||||
|
|
||||||
let hasOutput = false;
|
|
||||||
for (const [configKey, valueMessages] of Object.entries(notes)) {
|
|
||||||
const selectedValue = config[configKey];
|
|
||||||
if (!selectedValue || !valueMessages[selectedValue]) continue;
|
|
||||||
|
|
||||||
if (hasOutput) await prompts.log.message('');
|
|
||||||
hasOutput = true;
|
|
||||||
|
|
||||||
const message = valueMessages[selectedValue];
|
|
||||||
for (const line of message.trim().split('\n')) {
|
|
||||||
const trimmedLine = line.trim();
|
|
||||||
if (trimmedLine.endsWith(':') && !trimmedLine.startsWith(' ')) {
|
|
||||||
await prompts.log.info(color.bold(trimmedLine));
|
|
||||||
} else {
|
|
||||||
await prompts.log.message(color.dim(' ' + trimmedLine));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deep merge two objects
|
* Deep merge two objects
|
||||||
* @param {Object} target - Target object
|
* @param {Object} target - Target object
|
||||||
|
|
|
||||||
|
|
@ -527,30 +527,28 @@ class Installer {
|
||||||
const cachedModules = await fs.readdir(cacheDir, { withFileTypes: true });
|
const cachedModules = await fs.readdir(cacheDir, { withFileTypes: true });
|
||||||
|
|
||||||
for (const cachedModule of cachedModules) {
|
for (const cachedModule of cachedModules) {
|
||||||
const moduleId = cachedModule.name;
|
if (cachedModule.isDirectory()) {
|
||||||
const cachedPath = path.join(cacheDir, moduleId);
|
const moduleId = cachedModule.name;
|
||||||
|
|
||||||
// Skip if path doesn't exist (broken symlink, deleted dir) - avoids lstat ENOENT
|
// Skip if we already have this module from manifest
|
||||||
if (!(await fs.pathExists(cachedPath)) || !cachedModule.isDirectory()) {
|
if (customModulePaths.has(moduleId)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Skip if we already have this module from manifest
|
// Check if this is an external official module - skip cache for those
|
||||||
if (customModulePaths.has(moduleId)) {
|
const isExternal = await this.moduleManager.isExternalModule(moduleId);
|
||||||
continue;
|
if (isExternal) {
|
||||||
}
|
// External modules are handled via cloneExternalModule, not from cache
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// Check if this is an external official module - skip cache for those
|
const cachedPath = path.join(cacheDir, moduleId);
|
||||||
const isExternal = await this.moduleManager.isExternalModule(moduleId);
|
|
||||||
if (isExternal) {
|
|
||||||
// External modules are handled via cloneExternalModule, not from cache
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if this is actually a custom module (has module.yaml)
|
// Check if this is actually a custom module (has module.yaml)
|
||||||
const moduleYamlPath = path.join(cachedPath, 'module.yaml');
|
const moduleYamlPath = path.join(cachedPath, 'module.yaml');
|
||||||
if (await fs.pathExists(moduleYamlPath)) {
|
if (await fs.pathExists(moduleYamlPath)) {
|
||||||
customModulePaths.set(moduleId, cachedPath);
|
customModulePaths.set(moduleId, cachedPath);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -611,30 +609,28 @@ class Installer {
|
||||||
const cachedModules = await fs.readdir(cacheDir, { withFileTypes: true });
|
const cachedModules = await fs.readdir(cacheDir, { withFileTypes: true });
|
||||||
|
|
||||||
for (const cachedModule of cachedModules) {
|
for (const cachedModule of cachedModules) {
|
||||||
const moduleId = cachedModule.name;
|
if (cachedModule.isDirectory()) {
|
||||||
const cachedPath = path.join(cacheDir, moduleId);
|
const moduleId = cachedModule.name;
|
||||||
|
|
||||||
// Skip if path doesn't exist (broken symlink, deleted dir) - avoids lstat ENOENT
|
// Skip if we already have this module from manifest
|
||||||
if (!(await fs.pathExists(cachedPath)) || !cachedModule.isDirectory()) {
|
if (customModulePaths.has(moduleId)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Skip if we already have this module from manifest
|
// Check if this is an external official module - skip cache for those
|
||||||
if (customModulePaths.has(moduleId)) {
|
const isExternal = await this.moduleManager.isExternalModule(moduleId);
|
||||||
continue;
|
if (isExternal) {
|
||||||
}
|
// External modules are handled via cloneExternalModule, not from cache
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// Check if this is an external official module - skip cache for those
|
const cachedPath = path.join(cacheDir, moduleId);
|
||||||
const isExternal = await this.moduleManager.isExternalModule(moduleId);
|
|
||||||
if (isExternal) {
|
|
||||||
// External modules are handled via cloneExternalModule, not from cache
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if this is actually a custom module (has module.yaml)
|
// Check if this is actually a custom module (has module.yaml)
|
||||||
const moduleYamlPath = path.join(cachedPath, 'module.yaml');
|
const moduleYamlPath = path.join(cachedPath, 'module.yaml');
|
||||||
if (await fs.pathExists(moduleYamlPath)) {
|
if (await fs.pathExists(moduleYamlPath)) {
|
||||||
customModulePaths.set(moduleId, cachedPath);
|
customModulePaths.set(moduleId, cachedPath);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -953,11 +949,12 @@ class Installer {
|
||||||
if (!isCustomModule && config._customModuleSources && config._customModuleSources.has(moduleName)) {
|
if (!isCustomModule && config._customModuleSources && config._customModuleSources.has(moduleName)) {
|
||||||
customInfo = config._customModuleSources.get(moduleName);
|
customInfo = config._customModuleSources.get(moduleName);
|
||||||
isCustomModule = true;
|
isCustomModule = true;
|
||||||
if (customInfo.sourcePath && !customInfo.path) {
|
if (
|
||||||
customInfo.path = path.isAbsolute(customInfo.sourcePath)
|
customInfo.sourcePath &&
|
||||||
? customInfo.sourcePath
|
(customInfo.sourcePath.startsWith('_config') || customInfo.sourcePath.includes('_config/custom')) &&
|
||||||
: path.join(bmadDir, customInfo.sourcePath);
|
!customInfo.path
|
||||||
}
|
)
|
||||||
|
customInfo.path = customInfo.sourcePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Finally check regular custom content
|
// Finally check regular custom content
|
||||||
|
|
@ -1531,157 +1528,20 @@ class Installer {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Uninstall BMAD with selective removal options
|
* Uninstall BMAD
|
||||||
* @param {string} directory - Project directory
|
|
||||||
* @param {Object} options - Uninstall options
|
|
||||||
* @param {boolean} [options.removeModules=true] - Remove _bmad/ directory
|
|
||||||
* @param {boolean} [options.removeIdeConfigs=true] - Remove IDE configurations
|
|
||||||
* @param {boolean} [options.removeOutputFolder=false] - Remove user artifacts output folder
|
|
||||||
* @returns {Object} Result with success status and removed components
|
|
||||||
*/
|
*/
|
||||||
async uninstall(directory, options = {}) {
|
async uninstall(directory) {
|
||||||
const projectDir = path.resolve(directory);
|
const projectDir = path.resolve(directory);
|
||||||
const { bmadDir } = await this.findBmadDir(projectDir);
|
const { bmadDir } = await this.findBmadDir(projectDir);
|
||||||
|
|
||||||
if (!(await fs.pathExists(bmadDir))) {
|
|
||||||
return { success: false, reason: 'not-installed' };
|
|
||||||
}
|
|
||||||
|
|
||||||
// 1. DETECT: Read state BEFORE deleting anything
|
|
||||||
const existingInstall = await this.detector.detect(bmadDir);
|
|
||||||
const outputFolder = await this._readOutputFolder(bmadDir);
|
|
||||||
|
|
||||||
const removed = { modules: false, ideConfigs: false, outputFolder: false };
|
|
||||||
|
|
||||||
// 2. IDE CLEANUP (before _bmad/ deletion so configs are accessible)
|
|
||||||
if (options.removeIdeConfigs !== false) {
|
|
||||||
await this.uninstallIdeConfigs(projectDir, existingInstall, { silent: options.silent });
|
|
||||||
removed.ideConfigs = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 3. OUTPUT FOLDER (only if explicitly requested)
|
|
||||||
if (options.removeOutputFolder === true && outputFolder) {
|
|
||||||
removed.outputFolder = await this.uninstallOutputFolder(projectDir, outputFolder);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 4. BMAD DIRECTORY (last, after everything that needs it)
|
|
||||||
if (options.removeModules !== false) {
|
|
||||||
removed.modules = await this.uninstallModules(projectDir);
|
|
||||||
}
|
|
||||||
|
|
||||||
return { success: true, removed, version: existingInstall.version };
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Uninstall IDE configurations only
|
|
||||||
* @param {string} projectDir - Project directory
|
|
||||||
* @param {Object} existingInstall - Detection result from detector.detect()
|
|
||||||
* @param {Object} [options] - Options (e.g. { silent: true })
|
|
||||||
* @returns {Promise<Object>} Results from IDE cleanup
|
|
||||||
*/
|
|
||||||
async uninstallIdeConfigs(projectDir, existingInstall, options = {}) {
|
|
||||||
await this.ideManager.ensureInitialized();
|
|
||||||
const cleanupOptions = { isUninstall: true, silent: options.silent };
|
|
||||||
const ideList = existingInstall.ides || [];
|
|
||||||
if (ideList.length > 0) {
|
|
||||||
return this.ideManager.cleanupByList(projectDir, ideList, cleanupOptions);
|
|
||||||
}
|
|
||||||
return this.ideManager.cleanup(projectDir, cleanupOptions);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Remove user artifacts output folder
|
|
||||||
* @param {string} projectDir - Project directory
|
|
||||||
* @param {string} outputFolder - Output folder name (relative)
|
|
||||||
* @returns {Promise<boolean>} Whether the folder was removed
|
|
||||||
*/
|
|
||||||
async uninstallOutputFolder(projectDir, outputFolder) {
|
|
||||||
if (!outputFolder) return false;
|
|
||||||
const resolvedProject = path.resolve(projectDir);
|
|
||||||
const outputPath = path.resolve(resolvedProject, outputFolder);
|
|
||||||
if (!outputPath.startsWith(resolvedProject + path.sep)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (await fs.pathExists(outputPath)) {
|
|
||||||
await fs.remove(outputPath);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Remove the _bmad/ directory
|
|
||||||
* @param {string} projectDir - Project directory
|
|
||||||
* @returns {Promise<boolean>} Whether the directory was removed
|
|
||||||
*/
|
|
||||||
async uninstallModules(projectDir) {
|
|
||||||
const { bmadDir } = await this.findBmadDir(projectDir);
|
|
||||||
if (await fs.pathExists(bmadDir)) {
|
if (await fs.pathExists(bmadDir)) {
|
||||||
await fs.remove(bmadDir);
|
await fs.remove(bmadDir);
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the configured output folder name for a project
|
|
||||||
* Resolves bmadDir internally from projectDir
|
|
||||||
* @param {string} projectDir - Project directory
|
|
||||||
* @returns {string} Output folder name (relative, default: '_bmad-output')
|
|
||||||
*/
|
|
||||||
async getOutputFolder(projectDir) {
|
|
||||||
const { bmadDir } = await this.findBmadDir(projectDir);
|
|
||||||
return this._readOutputFolder(bmadDir);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Read the output_folder setting from module config files
|
|
||||||
* Checks bmm/config.yaml first, then other module configs
|
|
||||||
* @param {string} bmadDir - BMAD installation directory
|
|
||||||
* @returns {string} Output folder path or default
|
|
||||||
*/
|
|
||||||
async _readOutputFolder(bmadDir) {
|
|
||||||
const yaml = require('yaml');
|
|
||||||
|
|
||||||
// Check bmm/config.yaml first (most common)
|
|
||||||
const bmmConfigPath = path.join(bmadDir, 'bmm', 'config.yaml');
|
|
||||||
if (await fs.pathExists(bmmConfigPath)) {
|
|
||||||
try {
|
|
||||||
const content = await fs.readFile(bmmConfigPath, 'utf8');
|
|
||||||
const config = yaml.parse(content);
|
|
||||||
if (config && config.output_folder) {
|
|
||||||
// Strip {project-root}/ prefix if present
|
|
||||||
return config.output_folder.replace(/^\{project-root\}[/\\]/, '');
|
|
||||||
}
|
|
||||||
} catch {
|
|
||||||
// Fall through to other modules
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Scan other module config.yaml files
|
// Clean up IDE configurations
|
||||||
try {
|
await this.ideManager.cleanup(projectDir);
|
||||||
const entries = await fs.readdir(bmadDir, { withFileTypes: true });
|
|
||||||
for (const entry of entries) {
|
|
||||||
if (!entry.isDirectory() || entry.name === 'bmm' || entry.name.startsWith('_')) continue;
|
|
||||||
const configPath = path.join(bmadDir, entry.name, 'config.yaml');
|
|
||||||
if (await fs.pathExists(configPath)) {
|
|
||||||
try {
|
|
||||||
const content = await fs.readFile(configPath, 'utf8');
|
|
||||||
const config = yaml.parse(content);
|
|
||||||
if (config && config.output_folder) {
|
|
||||||
return config.output_folder.replace(/^\{project-root\}[/\\]/, '');
|
|
||||||
}
|
|
||||||
} catch {
|
|
||||||
// Continue scanning
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch {
|
|
||||||
// Directory scan failed
|
|
||||||
}
|
|
||||||
|
|
||||||
// Default fallback
|
return { success: true };
|
||||||
return '_bmad-output';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -2376,58 +2236,41 @@ class Installer {
|
||||||
const configuredIdes = existingInstall.ides || [];
|
const configuredIdes = existingInstall.ides || [];
|
||||||
const projectRoot = path.dirname(bmadDir);
|
const projectRoot = path.dirname(bmadDir);
|
||||||
|
|
||||||
// Get custom module sources: first from --custom-content (re-cache from source), then from cache
|
// Get custom module sources from cache
|
||||||
const customModuleSources = new Map();
|
const customModuleSources = new Map();
|
||||||
if (config.customContent?.sources?.length > 0) {
|
|
||||||
for (const source of config.customContent.sources) {
|
|
||||||
if (source.id && source.path && (await fs.pathExists(source.path))) {
|
|
||||||
customModuleSources.set(source.id, {
|
|
||||||
id: source.id,
|
|
||||||
name: source.name || source.id,
|
|
||||||
sourcePath: source.path,
|
|
||||||
cached: false, // From CLI, will be re-cached
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const cacheDir = path.join(bmadDir, '_config', 'custom');
|
const cacheDir = path.join(bmadDir, '_config', 'custom');
|
||||||
if (await fs.pathExists(cacheDir)) {
|
if (await fs.pathExists(cacheDir)) {
|
||||||
const cachedModules = await fs.readdir(cacheDir, { withFileTypes: true });
|
const cachedModules = await fs.readdir(cacheDir, { withFileTypes: true });
|
||||||
|
|
||||||
for (const cachedModule of cachedModules) {
|
for (const cachedModule of cachedModules) {
|
||||||
const moduleId = cachedModule.name;
|
if (cachedModule.isDirectory()) {
|
||||||
const cachedPath = path.join(cacheDir, moduleId);
|
const moduleId = cachedModule.name;
|
||||||
|
|
||||||
// Skip if path doesn't exist (broken symlink, deleted dir) - avoids lstat ENOENT
|
// Skip if we already have this module from manifest
|
||||||
if (!(await fs.pathExists(cachedPath))) {
|
if (customModuleSources.has(moduleId)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!cachedModule.isDirectory()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Skip if we already have this module from manifest
|
// Check if this is an external official module - skip cache for those
|
||||||
if (customModuleSources.has(moduleId)) {
|
const isExternal = await this.moduleManager.isExternalModule(moduleId);
|
||||||
continue;
|
if (isExternal) {
|
||||||
}
|
// External modules are handled via cloneExternalModule, not from cache
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// Check if this is an external official module - skip cache for those
|
const cachedPath = path.join(cacheDir, moduleId);
|
||||||
const isExternal = await this.moduleManager.isExternalModule(moduleId);
|
|
||||||
if (isExternal) {
|
|
||||||
// External modules are handled via cloneExternalModule, not from cache
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if this is actually a custom module (has module.yaml)
|
// Check if this is actually a custom module (has module.yaml)
|
||||||
const moduleYamlPath = path.join(cachedPath, 'module.yaml');
|
const moduleYamlPath = path.join(cachedPath, 'module.yaml');
|
||||||
if (await fs.pathExists(moduleYamlPath)) {
|
if (await fs.pathExists(moduleYamlPath)) {
|
||||||
// For quick update, we always rebuild from cache
|
// For quick update, we always rebuild from cache
|
||||||
customModuleSources.set(moduleId, {
|
customModuleSources.set(moduleId, {
|
||||||
id: moduleId,
|
id: moduleId,
|
||||||
name: moduleId, // We'll read the actual name if needed
|
name: moduleId, // We'll read the actual name if needed
|
||||||
sourcePath: cachedPath,
|
sourcePath: cachedPath,
|
||||||
cached: true, // Flag to indicate this is from cache
|
cached: true, // Flag to indicate this is from cache
|
||||||
});
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -2564,7 +2407,6 @@ class Installer {
|
||||||
_savedIdeConfigs: savedIdeConfigs, // Pass saved IDE configs to installer
|
_savedIdeConfigs: savedIdeConfigs, // Pass saved IDE configs to installer
|
||||||
_customModuleSources: customModuleSources, // Pass custom module sources for updates
|
_customModuleSources: customModuleSources, // Pass custom module sources for updates
|
||||||
_existingModules: installedModules, // Pass all installed modules for manifest generation
|
_existingModules: installedModules, // Pass all installed modules for manifest generation
|
||||||
customContent: config.customContent, // Pass through for re-caching from source
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Call the standard install method
|
// Call the standard install method
|
||||||
|
|
|
||||||
|
|
@ -456,18 +456,8 @@ LOAD and execute from: {project-root}/{{bmadFolderName}}/{{path}}
|
||||||
async cleanup(projectDir, options = {}) {
|
async cleanup(projectDir, options = {}) {
|
||||||
// Clean all target directories
|
// Clean all target directories
|
||||||
if (this.installerConfig?.targets) {
|
if (this.installerConfig?.targets) {
|
||||||
const parentDirs = new Set();
|
|
||||||
for (const target of this.installerConfig.targets) {
|
for (const target of this.installerConfig.targets) {
|
||||||
await this.cleanupTarget(projectDir, target.target_dir, options);
|
await this.cleanupTarget(projectDir, target.target_dir, options);
|
||||||
// Track parent directories for empty-dir cleanup
|
|
||||||
const parentDir = path.dirname(target.target_dir);
|
|
||||||
if (parentDir && parentDir !== '.') {
|
|
||||||
parentDirs.add(parentDir);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// After all targets cleaned, remove empty parent directories (recursive up to projectDir)
|
|
||||||
for (const parentDir of parentDirs) {
|
|
||||||
await this.removeEmptyParents(projectDir, parentDir);
|
|
||||||
}
|
}
|
||||||
} else if (this.installerConfig?.target_dir) {
|
} else if (this.installerConfig?.target_dir) {
|
||||||
await this.cleanupTarget(projectDir, this.installerConfig.target_dir, options);
|
await this.cleanupTarget(projectDir, this.installerConfig.target_dir, options);
|
||||||
|
|
@ -519,41 +509,6 @@ LOAD and execute from: {project-root}/{{bmadFolderName}}/{{path}}
|
||||||
if (removedCount > 0 && !options.silent) {
|
if (removedCount > 0 && !options.silent) {
|
||||||
await prompts.log.message(` Cleaned ${removedCount} BMAD files from ${targetDir}`);
|
await prompts.log.message(` Cleaned ${removedCount} BMAD files from ${targetDir}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove empty directory after cleanup
|
|
||||||
if (removedCount > 0) {
|
|
||||||
try {
|
|
||||||
const remaining = await fs.readdir(targetPath);
|
|
||||||
if (remaining.length === 0) {
|
|
||||||
await fs.remove(targetPath);
|
|
||||||
}
|
|
||||||
} catch {
|
|
||||||
// Directory may already be gone or in use — skip
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Recursively remove empty directories walking up from dir toward projectDir
|
|
||||||
* Stops at projectDir boundary — never removes projectDir itself
|
|
||||||
* @param {string} projectDir - Project root (boundary)
|
|
||||||
* @param {string} relativeDir - Relative directory to start from
|
|
||||||
*/
|
|
||||||
async removeEmptyParents(projectDir, relativeDir) {
|
|
||||||
let current = relativeDir;
|
|
||||||
let last = null;
|
|
||||||
while (current && current !== '.' && current !== last) {
|
|
||||||
last = current;
|
|
||||||
const fullPath = path.join(projectDir, current);
|
|
||||||
try {
|
|
||||||
if (!(await fs.pathExists(fullPath))) break;
|
|
||||||
const remaining = await fs.readdir(fullPath);
|
|
||||||
if (remaining.length > 0) break;
|
|
||||||
await fs.rmdir(fullPath);
|
|
||||||
} catch {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
current = path.dirname(current);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
const path = require('node:path');
|
const path = require('node:path');
|
||||||
const { BaseIdeSetup } = require('./_base-ide');
|
const { BaseIdeSetup } = require('./_base-ide');
|
||||||
const prompts = require('../../../lib/prompts');
|
const chalk = require('chalk');
|
||||||
const { AgentCommandGenerator } = require('./shared/agent-command-generator');
|
const { AgentCommandGenerator } = require('./shared/agent-command-generator');
|
||||||
const { BMAD_FOLDER_NAME, toDashPath } = require('./shared/path-utils');
|
const { BMAD_FOLDER_NAME, toDashPath } = require('./shared/path-utils');
|
||||||
const fs = require('fs-extra');
|
const fs = require('fs-extra');
|
||||||
|
|
@ -31,7 +31,7 @@ class GitHubCopilotSetup extends BaseIdeSetup {
|
||||||
* @param {Object} options - Setup options
|
* @param {Object} options - Setup options
|
||||||
*/
|
*/
|
||||||
async setup(projectDir, bmadDir, options = {}) {
|
async setup(projectDir, bmadDir, options = {}) {
|
||||||
if (!options.silent) await prompts.log.info(`Setting up ${this.name}...`);
|
console.log(chalk.cyan(`Setting up ${this.name}...`));
|
||||||
|
|
||||||
// Create .github/agents and .github/prompts directories
|
// Create .github/agents and .github/prompts directories
|
||||||
const githubDir = path.join(projectDir, this.githubDir);
|
const githubDir = path.join(projectDir, this.githubDir);
|
||||||
|
|
@ -66,15 +66,21 @@ class GitHubCopilotSetup extends BaseIdeSetup {
|
||||||
const targetPath = path.join(agentsDir, fileName);
|
const targetPath = path.join(agentsDir, fileName);
|
||||||
await this.writeFile(targetPath, agentContent);
|
await this.writeFile(targetPath, agentContent);
|
||||||
agentCount++;
|
agentCount++;
|
||||||
|
|
||||||
|
console.log(chalk.green(` ✓ Created agent: ${fileName}`));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generate prompt files from bmad-help.csv
|
// Generate prompt files from bmad-help.csv
|
||||||
const promptCount = await this.generatePromptFiles(projectDir, bmadDir, agentArtifacts, agentManifest);
|
const promptCount = await this.generatePromptFiles(projectDir, bmadDir, agentArtifacts, agentManifest);
|
||||||
|
|
||||||
// Generate copilot-instructions.md
|
// Generate copilot-instructions.md
|
||||||
await this.generateCopilotInstructions(projectDir, bmadDir, agentManifest, options);
|
await this.generateCopilotInstructions(projectDir, bmadDir, agentManifest);
|
||||||
|
|
||||||
if (!options.silent) await prompts.log.success(`${this.name} configured: ${agentCount} agents, ${promptCount} prompts → .github/`);
|
console.log(chalk.green(`\n✓ ${this.name} configured:`));
|
||||||
|
console.log(chalk.dim(` - ${agentCount} agents created in .github/agents/`));
|
||||||
|
console.log(chalk.dim(` - ${promptCount} prompts created in .github/prompts/`));
|
||||||
|
console.log(chalk.dim(` - copilot-instructions.md generated`));
|
||||||
|
console.log(chalk.dim(` - Destination: .github/`));
|
||||||
|
|
||||||
return {
|
return {
|
||||||
success: true,
|
success: true,
|
||||||
|
|
@ -400,7 +406,7 @@ tools: ${toolsStr}
|
||||||
* @param {string} bmadDir - BMAD installation directory
|
* @param {string} bmadDir - BMAD installation directory
|
||||||
* @param {Map} agentManifest - Agent manifest data
|
* @param {Map} agentManifest - Agent manifest data
|
||||||
*/
|
*/
|
||||||
async generateCopilotInstructions(projectDir, bmadDir, agentManifest, options = {}) {
|
async generateCopilotInstructions(projectDir, bmadDir, agentManifest) {
|
||||||
const configVars = await this.loadModuleConfig(bmadDir);
|
const configVars = await this.loadModuleConfig(bmadDir);
|
||||||
|
|
||||||
// Build the agents table from the manifest
|
// Build the agents table from the manifest
|
||||||
|
|
@ -489,16 +495,19 @@ Type \`/bmad-\` in Copilot Chat to see all available BMAD workflows and agent ac
|
||||||
const after = existing.slice(endIdx + markerEnd.length);
|
const after = existing.slice(endIdx + markerEnd.length);
|
||||||
const merged = `${before}${markedContent}${after}`;
|
const merged = `${before}${markedContent}${after}`;
|
||||||
await this.writeFile(instructionsPath, merged);
|
await this.writeFile(instructionsPath, merged);
|
||||||
|
console.log(chalk.green(' ✓ Updated BMAD section in copilot-instructions.md'));
|
||||||
} else {
|
} else {
|
||||||
// Existing file without markers — back it up before overwriting
|
// Existing file without markers — back it up before overwriting
|
||||||
const backupPath = `${instructionsPath}.bak`;
|
const backupPath = `${instructionsPath}.bak`;
|
||||||
await fs.copy(instructionsPath, backupPath);
|
await fs.copy(instructionsPath, backupPath);
|
||||||
if (!options.silent) await prompts.log.warn(` Backed up copilot-instructions.md → .bak`);
|
console.log(chalk.yellow(` ⚠ Backed up existing copilot-instructions.md → copilot-instructions.md.bak`));
|
||||||
await this.writeFile(instructionsPath, `${markedContent}\n`);
|
await this.writeFile(instructionsPath, `${markedContent}\n`);
|
||||||
|
console.log(chalk.green(' ✓ Generated copilot-instructions.md (with BMAD markers)'));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// No existing file — create fresh with markers
|
// No existing file — create fresh with markers
|
||||||
await this.writeFile(instructionsPath, `${markedContent}\n`);
|
await this.writeFile(instructionsPath, `${markedContent}\n`);
|
||||||
|
console.log(chalk.green(' ✓ Generated copilot-instructions.md'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -598,7 +607,7 @@ Type \`/bmad-\` in Copilot Chat to see all available BMAD workflows and agent ac
|
||||||
/**
|
/**
|
||||||
* Cleanup GitHub Copilot configuration - surgically remove only BMAD files
|
* Cleanup GitHub Copilot configuration - surgically remove only BMAD files
|
||||||
*/
|
*/
|
||||||
async cleanup(projectDir, options = {}) {
|
async cleanup(projectDir) {
|
||||||
// Clean up agents directory
|
// Clean up agents directory
|
||||||
const agentsDir = path.join(projectDir, this.githubDir, this.agentsDir);
|
const agentsDir = path.join(projectDir, this.githubDir, this.agentsDir);
|
||||||
if (await fs.pathExists(agentsDir)) {
|
if (await fs.pathExists(agentsDir)) {
|
||||||
|
|
@ -612,8 +621,8 @@ Type \`/bmad-\` in Copilot Chat to see all available BMAD workflows and agent ac
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (removed > 0 && !options.silent) {
|
if (removed > 0) {
|
||||||
await prompts.log.message(` Cleaned up ${removed} existing BMAD agents`);
|
console.log(chalk.dim(` Cleaned up ${removed} existing BMAD agents`));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -630,70 +639,16 @@ Type \`/bmad-\` in Copilot Chat to see all available BMAD workflows and agent ac
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (removed > 0 && !options.silent) {
|
if (removed > 0) {
|
||||||
await prompts.log.message(` Cleaned up ${removed} existing BMAD prompts`);
|
console.log(chalk.dim(` Cleaned up ${removed} existing BMAD prompts`));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// During uninstall, also strip BMAD markers from copilot-instructions.md.
|
// Note: copilot-instructions.md is NOT cleaned up here.
|
||||||
// During reinstall (default), this is skipped because generateCopilotInstructions()
|
// generateCopilotInstructions() handles marker-based replacement in a single
|
||||||
// handles marker-based replacement in a single read-modify-write pass,
|
// read-modify-write pass, which correctly preserves user content outside the markers.
|
||||||
// which correctly preserves user content outside the markers.
|
// Stripping markers here would cause generation to treat the file as legacy (no markers)
|
||||||
if (options.isUninstall) {
|
// and overwrite user content.
|
||||||
await this.cleanupCopilotInstructions(projectDir, options);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Strip BMAD marker section from copilot-instructions.md
|
|
||||||
* If file becomes empty after stripping, delete it.
|
|
||||||
* If a .bak backup exists and the main file was deleted, restore the backup.
|
|
||||||
* @param {string} projectDir - Project directory
|
|
||||||
* @param {Object} [options] - Options (e.g. { silent: true })
|
|
||||||
*/
|
|
||||||
async cleanupCopilotInstructions(projectDir, options = {}) {
|
|
||||||
const instructionsPath = path.join(projectDir, this.githubDir, 'copilot-instructions.md');
|
|
||||||
const backupPath = `${instructionsPath}.bak`;
|
|
||||||
|
|
||||||
if (!(await fs.pathExists(instructionsPath))) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const content = await fs.readFile(instructionsPath, 'utf8');
|
|
||||||
const markerStart = '<!-- BMAD:START -->';
|
|
||||||
const markerEnd = '<!-- BMAD:END -->';
|
|
||||||
const startIdx = content.indexOf(markerStart);
|
|
||||||
const endIdx = content.indexOf(markerEnd);
|
|
||||||
|
|
||||||
if (startIdx === -1 || endIdx === -1 || endIdx <= startIdx) {
|
|
||||||
return; // No valid markers found
|
|
||||||
}
|
|
||||||
|
|
||||||
// Strip the marker section (including markers)
|
|
||||||
const before = content.slice(0, startIdx);
|
|
||||||
const after = content.slice(endIdx + markerEnd.length);
|
|
||||||
const cleaned = before + after;
|
|
||||||
|
|
||||||
if (cleaned.trim().length === 0) {
|
|
||||||
// File is empty after stripping — delete it
|
|
||||||
await fs.remove(instructionsPath);
|
|
||||||
|
|
||||||
// If backup exists, restore it
|
|
||||||
if (await fs.pathExists(backupPath)) {
|
|
||||||
await fs.rename(backupPath, instructionsPath);
|
|
||||||
if (!options.silent) {
|
|
||||||
await prompts.log.message(' Restored copilot-instructions.md from backup');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// Write cleaned content back (preserve original whitespace)
|
|
||||||
await fs.writeFile(instructionsPath, cleaned, 'utf8');
|
|
||||||
|
|
||||||
// If backup exists, it's stale now — remove it
|
|
||||||
if (await fs.pathExists(backupPath)) {
|
|
||||||
await fs.remove(backupPath);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -216,14 +216,13 @@ class IdeManager {
|
||||||
/**
|
/**
|
||||||
* Cleanup IDE configurations
|
* Cleanup IDE configurations
|
||||||
* @param {string} projectDir - Project directory
|
* @param {string} projectDir - Project directory
|
||||||
* @param {Object} [options] - Cleanup options passed through to handlers
|
|
||||||
*/
|
*/
|
||||||
async cleanup(projectDir, options = {}) {
|
async cleanup(projectDir) {
|
||||||
const results = [];
|
const results = [];
|
||||||
|
|
||||||
for (const [name, handler] of this.handlers) {
|
for (const [name, handler] of this.handlers) {
|
||||||
try {
|
try {
|
||||||
await handler.cleanup(projectDir, options);
|
await handler.cleanup(projectDir);
|
||||||
results.push({ ide: name, success: true });
|
results.push({ ide: name, success: true });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
results.push({ ide: name, success: false, error: error.message });
|
results.push({ ide: name, success: false, error: error.message });
|
||||||
|
|
@ -233,40 +232,6 @@ class IdeManager {
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Cleanup only the IDEs in the provided list
|
|
||||||
* Falls back to cleanup() (all handlers) if ideList is empty or undefined
|
|
||||||
* @param {string} projectDir - Project directory
|
|
||||||
* @param {Array<string>} ideList - List of IDE names to clean up
|
|
||||||
* @param {Object} [options] - Cleanup options passed through to handlers
|
|
||||||
* @returns {Array} Results array
|
|
||||||
*/
|
|
||||||
async cleanupByList(projectDir, ideList, options = {}) {
|
|
||||||
if (!ideList || ideList.length === 0) {
|
|
||||||
return this.cleanup(projectDir, options);
|
|
||||||
}
|
|
||||||
|
|
||||||
await this.ensureInitialized();
|
|
||||||
const results = [];
|
|
||||||
|
|
||||||
// Build lowercase lookup for case-insensitive matching
|
|
||||||
const lowercaseHandlers = new Map([...this.handlers.entries()].map(([k, v]) => [k.toLowerCase(), v]));
|
|
||||||
|
|
||||||
for (const ideName of ideList) {
|
|
||||||
const handler = lowercaseHandlers.get(ideName.toLowerCase());
|
|
||||||
if (!handler) continue;
|
|
||||||
|
|
||||||
try {
|
|
||||||
await handler.cleanup(projectDir, options);
|
|
||||||
results.push({ ide: ideName, success: true });
|
|
||||||
} catch (error) {
|
|
||||||
results.push({ ide: ideName, success: false, error: error.message });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return results;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get list of supported IDEs
|
* Get list of supported IDEs
|
||||||
* @returns {Array} List of supported IDE names
|
* @returns {Array} List of supported IDE names
|
||||||
|
|
|
||||||
|
|
@ -734,10 +734,8 @@ class ModuleManager {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Skip module root config.yaml only - generated by config collector with actual values
|
// Skip config.yaml templates - we'll generate clean ones with actual values
|
||||||
// Workflow-level config.yaml (e.g. workflows/orchestrate-story/config.yaml) must be copied
|
if (file === 'config.yaml' || file.endsWith('/config.yaml')) {
|
||||||
// for custom modules that use workflow-specific configuration
|
|
||||||
if (file === 'config.yaml') {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -245,48 +245,11 @@ class UI {
|
||||||
|
|
||||||
// Handle quick update separately
|
// Handle quick update separately
|
||||||
if (actionType === 'quick-update') {
|
if (actionType === 'quick-update') {
|
||||||
// Pass --custom-content through so installer can re-cache if cache is missing
|
// Quick update doesn't install custom content - just updates existing modules
|
||||||
let customContentForQuickUpdate = { hasCustomContent: false };
|
|
||||||
if (options.customContent) {
|
|
||||||
const paths = options.customContent
|
|
||||||
.split(',')
|
|
||||||
.map((p) => p.trim())
|
|
||||||
.filter(Boolean);
|
|
||||||
if (paths.length > 0) {
|
|
||||||
const customPaths = [];
|
|
||||||
const selectedModuleIds = [];
|
|
||||||
const sources = [];
|
|
||||||
for (const customPath of paths) {
|
|
||||||
const expandedPath = this.expandUserPath(customPath);
|
|
||||||
const validation = this.validateCustomContentPathSync(expandedPath);
|
|
||||||
if (validation) continue;
|
|
||||||
let moduleMeta;
|
|
||||||
try {
|
|
||||||
const moduleYamlPath = path.join(expandedPath, 'module.yaml');
|
|
||||||
moduleMeta = require('yaml').parse(await fs.readFile(moduleYamlPath, 'utf-8'));
|
|
||||||
} catch {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (!moduleMeta?.code) continue;
|
|
||||||
customPaths.push(expandedPath);
|
|
||||||
selectedModuleIds.push(moduleMeta.code);
|
|
||||||
sources.push({ path: expandedPath, id: moduleMeta.code, name: moduleMeta.name || moduleMeta.code });
|
|
||||||
}
|
|
||||||
if (customPaths.length > 0) {
|
|
||||||
customContentForQuickUpdate = {
|
|
||||||
hasCustomContent: true,
|
|
||||||
selected: true,
|
|
||||||
sources,
|
|
||||||
selectedFiles: customPaths.map((p) => path.join(p, 'module.yaml')),
|
|
||||||
selectedModuleIds,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return {
|
return {
|
||||||
actionType: 'quick-update',
|
actionType: 'quick-update',
|
||||||
directory: confirmedDirectory,
|
directory: confirmedDirectory,
|
||||||
customContent: customContentForQuickUpdate,
|
customContent: { hasCustomContent: false },
|
||||||
skipPrompts: options.yes || false,
|
skipPrompts: options.yes || false,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
@ -342,7 +305,6 @@ class UI {
|
||||||
// Build custom content config similar to promptCustomContentSource
|
// Build custom content config similar to promptCustomContentSource
|
||||||
const customPaths = [];
|
const customPaths = [];
|
||||||
const selectedModuleIds = [];
|
const selectedModuleIds = [];
|
||||||
const sources = [];
|
|
||||||
|
|
||||||
for (const customPath of paths) {
|
for (const customPath of paths) {
|
||||||
const expandedPath = this.expandUserPath(customPath);
|
const expandedPath = this.expandUserPath(customPath);
|
||||||
|
|
@ -364,11 +326,6 @@ class UI {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!moduleMeta) {
|
|
||||||
await prompts.log.warn(`Skipping custom content path: ${customPath} - module.yaml is empty`);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!moduleMeta.code) {
|
if (!moduleMeta.code) {
|
||||||
await prompts.log.warn(`Skipping custom content path: ${customPath} - module.yaml missing 'code' field`);
|
await prompts.log.warn(`Skipping custom content path: ${customPath} - module.yaml missing 'code' field`);
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -376,11 +333,6 @@ class UI {
|
||||||
|
|
||||||
customPaths.push(expandedPath);
|
customPaths.push(expandedPath);
|
||||||
selectedModuleIds.push(moduleMeta.code);
|
selectedModuleIds.push(moduleMeta.code);
|
||||||
sources.push({
|
|
||||||
path: expandedPath,
|
|
||||||
id: moduleMeta.code,
|
|
||||||
name: moduleMeta.name || moduleMeta.code,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (customPaths.length > 0) {
|
if (customPaths.length > 0) {
|
||||||
|
|
@ -388,9 +340,7 @@ class UI {
|
||||||
selectedCustomModules: selectedModuleIds,
|
selectedCustomModules: selectedModuleIds,
|
||||||
customContentConfig: {
|
customContentConfig: {
|
||||||
hasCustomContent: true,
|
hasCustomContent: true,
|
||||||
selected: true,
|
paths: customPaths,
|
||||||
sources,
|
|
||||||
selectedFiles: customPaths.map((p) => path.join(p, 'module.yaml')),
|
|
||||||
selectedModuleIds: selectedModuleIds,
|
selectedModuleIds: selectedModuleIds,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
@ -496,7 +446,6 @@ class UI {
|
||||||
// Build custom content config similar to promptCustomContentSource
|
// Build custom content config similar to promptCustomContentSource
|
||||||
const customPaths = [];
|
const customPaths = [];
|
||||||
const selectedModuleIds = [];
|
const selectedModuleIds = [];
|
||||||
const sources = [];
|
|
||||||
|
|
||||||
for (const customPath of paths) {
|
for (const customPath of paths) {
|
||||||
const expandedPath = this.expandUserPath(customPath);
|
const expandedPath = this.expandUserPath(customPath);
|
||||||
|
|
@ -518,11 +467,6 @@ class UI {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!moduleMeta) {
|
|
||||||
await prompts.log.warn(`Skipping custom content path: ${customPath} - module.yaml is empty`);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!moduleMeta.code) {
|
if (!moduleMeta.code) {
|
||||||
await prompts.log.warn(`Skipping custom content path: ${customPath} - module.yaml missing 'code' field`);
|
await prompts.log.warn(`Skipping custom content path: ${customPath} - module.yaml missing 'code' field`);
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -530,19 +474,12 @@ class UI {
|
||||||
|
|
||||||
customPaths.push(expandedPath);
|
customPaths.push(expandedPath);
|
||||||
selectedModuleIds.push(moduleMeta.code);
|
selectedModuleIds.push(moduleMeta.code);
|
||||||
sources.push({
|
|
||||||
path: expandedPath,
|
|
||||||
id: moduleMeta.code,
|
|
||||||
name: moduleMeta.name || moduleMeta.code,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (customPaths.length > 0) {
|
if (customPaths.length > 0) {
|
||||||
customContentConfig = {
|
customContentConfig = {
|
||||||
hasCustomContent: true,
|
hasCustomContent: true,
|
||||||
selected: true,
|
paths: customPaths,
|
||||||
sources,
|
|
||||||
selectedFiles: customPaths.map((p) => path.join(p, 'module.yaml')),
|
|
||||||
selectedModuleIds: selectedModuleIds,
|
selectedModuleIds: selectedModuleIds,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue