2025-09-28 23:17:07 -05:00
|
|
|
const path = require('node:path');
|
|
|
|
|
const { BaseIdeSetup } = require('./_base-ide');
|
|
|
|
|
const chalk = require('chalk');
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Cursor IDE setup handler
|
|
|
|
|
*/
|
|
|
|
|
class CursorSetup extends BaseIdeSetup {
|
|
|
|
|
constructor() {
|
|
|
|
|
super('cursor', 'Cursor', true); // preferred IDE
|
|
|
|
|
this.configDir = '.cursor';
|
|
|
|
|
this.rulesDir = 'rules';
|
|
|
|
|
}
|
|
|
|
|
|
2025-11-06 22:45:29 -06:00
|
|
|
/**
|
|
|
|
|
* Cleanup old BMAD installation before reinstalling
|
|
|
|
|
* @param {string} projectDir - Project directory
|
|
|
|
|
*/
|
|
|
|
|
async cleanup(projectDir) {
|
|
|
|
|
const fs = require('fs-extra');
|
|
|
|
|
const bmadRulesDir = path.join(projectDir, this.configDir, this.rulesDir, 'bmad');
|
|
|
|
|
|
|
|
|
|
if (await fs.pathExists(bmadRulesDir)) {
|
|
|
|
|
await fs.remove(bmadRulesDir);
|
|
|
|
|
console.log(chalk.dim(` Removed old BMAD rules from ${this.name}`));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-09-28 23:17:07 -05:00
|
|
|
/**
|
|
|
|
|
* Setup Cursor IDE configuration
|
|
|
|
|
* @param {string} projectDir - Project directory
|
|
|
|
|
* @param {string} bmadDir - BMAD installation directory
|
|
|
|
|
* @param {Object} options - Setup options
|
|
|
|
|
*/
|
|
|
|
|
async setup(projectDir, bmadDir, options = {}) {
|
|
|
|
|
console.log(chalk.cyan(`Setting up ${this.name}...`));
|
|
|
|
|
|
2025-11-06 22:45:29 -06:00
|
|
|
// Clean up old BMAD installation first
|
|
|
|
|
await this.cleanup(projectDir);
|
|
|
|
|
|
2025-09-28 23:17:07 -05:00
|
|
|
// Create .cursor/rules directory structure
|
|
|
|
|
const cursorDir = path.join(projectDir, this.configDir);
|
|
|
|
|
const rulesDir = path.join(cursorDir, this.rulesDir);
|
|
|
|
|
const bmadRulesDir = path.join(rulesDir, 'bmad');
|
|
|
|
|
|
|
|
|
|
await this.ensureDir(bmadRulesDir);
|
|
|
|
|
|
2025-10-26 19:38:38 -05:00
|
|
|
// Get agents, tasks, tools, and workflows (standalone only)
|
2025-09-28 23:17:07 -05:00
|
|
|
const agents = await this.getAgents(bmadDir);
|
2025-10-26 19:38:38 -05:00
|
|
|
const tasks = await this.getTasks(bmadDir, true);
|
|
|
|
|
const tools = await this.getTools(bmadDir, true);
|
|
|
|
|
const workflows = await this.getWorkflows(bmadDir, true);
|
2025-09-28 23:17:07 -05:00
|
|
|
|
|
|
|
|
// Create directories for each module
|
|
|
|
|
const modules = new Set();
|
2025-10-26 19:38:38 -05:00
|
|
|
for (const item of [...agents, ...tasks, ...tools, ...workflows]) modules.add(item.module);
|
2025-09-28 23:17:07 -05:00
|
|
|
|
|
|
|
|
for (const module of modules) {
|
|
|
|
|
await this.ensureDir(path.join(bmadRulesDir, module));
|
|
|
|
|
await this.ensureDir(path.join(bmadRulesDir, module, 'agents'));
|
|
|
|
|
await this.ensureDir(path.join(bmadRulesDir, module, 'tasks'));
|
2025-10-26 19:38:38 -05:00
|
|
|
await this.ensureDir(path.join(bmadRulesDir, module, 'tools'));
|
|
|
|
|
await this.ensureDir(path.join(bmadRulesDir, module, 'workflows'));
|
2025-09-28 23:17:07 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Process and copy agents
|
|
|
|
|
let agentCount = 0;
|
|
|
|
|
for (const agent of agents) {
|
|
|
|
|
const content = await this.readAndProcess(agent.path, {
|
|
|
|
|
module: agent.module,
|
|
|
|
|
name: agent.name,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const targetPath = path.join(bmadRulesDir, agent.module, 'agents', `${agent.name}.mdc`);
|
|
|
|
|
|
|
|
|
|
await this.writeFile(targetPath, content);
|
|
|
|
|
agentCount++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Process and copy tasks
|
|
|
|
|
let taskCount = 0;
|
|
|
|
|
for (const task of tasks) {
|
|
|
|
|
const content = await this.readAndProcess(task.path, {
|
|
|
|
|
module: task.module,
|
|
|
|
|
name: task.name,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const targetPath = path.join(bmadRulesDir, task.module, 'tasks', `${task.name}.mdc`);
|
|
|
|
|
|
|
|
|
|
await this.writeFile(targetPath, content);
|
|
|
|
|
taskCount++;
|
|
|
|
|
}
|
|
|
|
|
|
2025-10-26 19:38:38 -05:00
|
|
|
// Process and copy tools
|
|
|
|
|
let toolCount = 0;
|
|
|
|
|
for (const tool of tools) {
|
|
|
|
|
const content = await this.readAndProcess(tool.path, {
|
|
|
|
|
module: tool.module,
|
|
|
|
|
name: tool.name,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const targetPath = path.join(bmadRulesDir, tool.module, 'tools', `${tool.name}.mdc`);
|
|
|
|
|
|
|
|
|
|
await this.writeFile(targetPath, content);
|
|
|
|
|
toolCount++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Process and copy workflows
|
|
|
|
|
let workflowCount = 0;
|
|
|
|
|
for (const workflow of workflows) {
|
|
|
|
|
const content = await this.readAndProcess(workflow.path, {
|
|
|
|
|
module: workflow.module,
|
|
|
|
|
name: workflow.name,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const targetPath = path.join(bmadRulesDir, workflow.module, 'workflows', `${workflow.name}.mdc`);
|
|
|
|
|
|
|
|
|
|
await this.writeFile(targetPath, content);
|
|
|
|
|
workflowCount++;
|
|
|
|
|
}
|
|
|
|
|
|
2025-09-28 23:17:07 -05:00
|
|
|
// Create BMAD index file (but NOT .cursorrules - user manages that)
|
2025-10-26 19:38:38 -05:00
|
|
|
await this.createBMADIndex(bmadRulesDir, agents, tasks, tools, workflows, modules);
|
2025-09-28 23:17:07 -05:00
|
|
|
|
|
|
|
|
console.log(chalk.green(`✓ ${this.name} configured:`));
|
|
|
|
|
console.log(chalk.dim(` - ${agentCount} agents installed`));
|
|
|
|
|
console.log(chalk.dim(` - ${taskCount} tasks installed`));
|
2025-10-26 19:38:38 -05:00
|
|
|
console.log(chalk.dim(` - ${toolCount} tools installed`));
|
|
|
|
|
console.log(chalk.dim(` - ${workflowCount} workflows installed`));
|
2025-09-28 23:17:07 -05:00
|
|
|
console.log(chalk.dim(` - Rules directory: ${path.relative(projectDir, bmadRulesDir)}`));
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
success: true,
|
|
|
|
|
agents: agentCount,
|
|
|
|
|
tasks: taskCount,
|
2025-10-26 19:38:38 -05:00
|
|
|
tools: toolCount,
|
|
|
|
|
workflows: workflowCount,
|
2025-09-28 23:17:07 -05:00
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Create BMAD index file for easy navigation
|
|
|
|
|
*/
|
2025-10-26 19:38:38 -05:00
|
|
|
async createBMADIndex(bmadRulesDir, agents, tasks, tools, workflows, modules) {
|
2025-09-28 23:17:07 -05:00
|
|
|
const indexPath = path.join(bmadRulesDir, 'index.mdc');
|
|
|
|
|
|
|
|
|
|
let content = `---
|
|
|
|
|
description: BMAD Method - Master Index
|
2025-10-26 19:38:38 -05:00
|
|
|
globs:
|
2025-09-28 23:17:07 -05:00
|
|
|
alwaysApply: true
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
# BMAD Method - Cursor Rules Index
|
|
|
|
|
|
2025-10-26 19:38:38 -05:00
|
|
|
This is the master index for all BMAD agents, tasks, tools, and workflows available in your project.
|
2025-09-28 23:17:07 -05:00
|
|
|
|
|
|
|
|
## Installation Complete!
|
|
|
|
|
|
|
|
|
|
BMAD rules have been installed to: \`.cursor/rules/bmad/\`
|
|
|
|
|
|
|
|
|
|
**Note:** BMAD does not modify your \`.cursorrules\` file. You manage that separately.
|
|
|
|
|
|
|
|
|
|
## How to Use
|
|
|
|
|
|
|
|
|
|
- Reference specific agents: @bmad/{module}/agents/{agent-name}
|
|
|
|
|
- Reference specific tasks: @bmad/{module}/tasks/{task-name}
|
2025-10-26 19:38:38 -05:00
|
|
|
- Reference specific tools: @bmad/{module}/tools/{tool-name}
|
|
|
|
|
- Reference specific workflows: @bmad/{module}/workflows/{workflow-name}
|
2025-09-28 23:17:07 -05:00
|
|
|
- Reference entire modules: @bmad/{module}
|
|
|
|
|
- Reference this index: @bmad/index
|
|
|
|
|
|
|
|
|
|
## Available Modules
|
|
|
|
|
|
|
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
for (const module of modules) {
|
|
|
|
|
content += `### ${module.toUpperCase()}\n\n`;
|
|
|
|
|
|
|
|
|
|
// List agents for this module
|
|
|
|
|
const moduleAgents = agents.filter((a) => a.module === module);
|
|
|
|
|
if (moduleAgents.length > 0) {
|
|
|
|
|
content += `**Agents:**\n`;
|
|
|
|
|
for (const agent of moduleAgents) {
|
|
|
|
|
content += `- @bmad/${module}/agents/${agent.name} - ${agent.name}\n`;
|
|
|
|
|
}
|
|
|
|
|
content += '\n';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// List tasks for this module
|
|
|
|
|
const moduleTasks = tasks.filter((t) => t.module === module);
|
|
|
|
|
if (moduleTasks.length > 0) {
|
|
|
|
|
content += `**Tasks:**\n`;
|
|
|
|
|
for (const task of moduleTasks) {
|
|
|
|
|
content += `- @bmad/${module}/tasks/${task.name} - ${task.name}\n`;
|
|
|
|
|
}
|
|
|
|
|
content += '\n';
|
|
|
|
|
}
|
2025-10-26 19:38:38 -05:00
|
|
|
|
|
|
|
|
// List tools for this module
|
|
|
|
|
const moduleTools = tools.filter((t) => t.module === module);
|
|
|
|
|
if (moduleTools.length > 0) {
|
|
|
|
|
content += `**Tools:**\n`;
|
|
|
|
|
for (const tool of moduleTools) {
|
|
|
|
|
content += `- @bmad/${module}/tools/${tool.name} - ${tool.name}\n`;
|
|
|
|
|
}
|
|
|
|
|
content += '\n';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// List workflows for this module
|
|
|
|
|
const moduleWorkflows = workflows.filter((w) => w.module === module);
|
|
|
|
|
if (moduleWorkflows.length > 0) {
|
|
|
|
|
content += `**Workflows:**\n`;
|
|
|
|
|
for (const workflow of moduleWorkflows) {
|
|
|
|
|
content += `- @bmad/${module}/workflows/${workflow.name} - ${workflow.name}\n`;
|
|
|
|
|
}
|
|
|
|
|
content += '\n';
|
|
|
|
|
}
|
2025-09-28 23:17:07 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
content += `
|
|
|
|
|
## Quick Reference
|
|
|
|
|
|
|
|
|
|
- All BMAD rules are Manual type - reference them explicitly when needed
|
|
|
|
|
- Agents provide persona-based assistance with specific expertise
|
|
|
|
|
- Tasks are reusable workflows for common operations
|
2025-10-26 19:38:38 -05:00
|
|
|
- Tools provide specialized functionality
|
|
|
|
|
- Workflows orchestrate multi-step processes
|
2025-09-28 23:17:07 -05:00
|
|
|
- Each agent includes an activation block for proper initialization
|
|
|
|
|
|
|
|
|
|
## Configuration
|
|
|
|
|
|
|
|
|
|
BMAD rules are configured as Manual rules (alwaysApply: false) to give you control
|
|
|
|
|
over when they're included in your context. Reference them explicitly when you need
|
2025-10-26 19:38:38 -05:00
|
|
|
specific agent expertise, task workflows, tools, or guided workflows.
|
2025-09-28 23:17:07 -05:00
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
await this.writeFile(indexPath, content);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Read and process file content
|
|
|
|
|
*/
|
|
|
|
|
async readAndProcess(filePath, metadata) {
|
|
|
|
|
const fs = require('fs-extra');
|
|
|
|
|
const content = await fs.readFile(filePath, 'utf8');
|
|
|
|
|
return this.processContent(content, metadata);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Override processContent to add MDC metadata header for Cursor
|
|
|
|
|
* @param {string} content - File content
|
|
|
|
|
* @param {Object} metadata - File metadata
|
|
|
|
|
* @returns {string} Processed content with MDC header
|
|
|
|
|
*/
|
|
|
|
|
processContent(content, metadata = {}) {
|
|
|
|
|
// First apply base processing (includes activation injection for agents)
|
|
|
|
|
let processed = super.processContent(content, metadata);
|
|
|
|
|
|
Major Enhancements:
- Installation path is now fully configurable, allowing users to specify custom installation directories during setup
- Default installation location changed to .bmad (hidden directory) for cleaner project root organization
Web Bundle Improvements:
- All web bundles (single agent and team) now include party mode support for multi-agent collaboration!
- Advanced elicitation capabilities integrated into standalone agents
- All bundles enhanced with party mode agent manifests
- Added default-party.csv files to bmm, bmgd, and cis module teams
- The default party file is what will be used with single agent bundles. teams can customize for different party configurations before web bundling through a setting in the team yaml file
- New web bundle outputs for all agents (analyst, architect, dev, pm, sm, tea, tech-writer, ux-designer, game-*, creative-squad)
Phase 4 Workflow Updates (In Progress):
- Initiated shift to separate phase 4 implementation artifacts from documentation
- Phase 4 implementation artifacts (stories, code review, sprint plan, context files) will move to dedicated location outside docs folder
- Installer questions and configuration added for artifact path selection
- Updated workflow.yaml files for code-review, sprint-planning, story-context, epic-tech-context, and retrospective workflows to support this, but still might require some udpates
Additional Changes:
- New agent and action command header models for standardization
- Enhanced web-bundle-activation-steps fragment
- Updated web-bundler.js to support new structure
- VS Code settings updated for new .bmad directory
- Party mode instructions and workflow enhanced for better orchestration
IDE Installer Updates:
- Show version number of installer in cli
- improved Installer UX
- Gemini TOML Improved to have clear loading instructions with @ commands
- All tools agent launcher mds improved to use a central file template critical indication isntead of hardcoding in 2 different locations.
2025-11-09 17:39:05 -06:00
|
|
|
// Strip any existing frontmatter from the processed content
|
|
|
|
|
// This prevents duplicate frontmatter blocks
|
|
|
|
|
const frontmatterRegex = /^---\s*\n[\s\S]*?\n---\s*\n/;
|
|
|
|
|
if (frontmatterRegex.test(processed)) {
|
|
|
|
|
processed = processed.replace(frontmatterRegex, '');
|
|
|
|
|
}
|
|
|
|
|
|
2025-09-28 23:17:07 -05:00
|
|
|
// Determine the type and description based on content
|
|
|
|
|
const isAgent = content.includes('<agent');
|
|
|
|
|
const isTask = content.includes('<task');
|
2025-10-26 19:38:38 -05:00
|
|
|
const isTool = content.includes('<tool');
|
|
|
|
|
const isWorkflow = content.includes('workflow:') || content.includes('name:');
|
2025-09-28 23:17:07 -05:00
|
|
|
|
|
|
|
|
let description = '';
|
|
|
|
|
let globs = '';
|
|
|
|
|
|
|
|
|
|
if (isAgent) {
|
|
|
|
|
// Extract agent title if available
|
|
|
|
|
const titleMatch = content.match(/title="([^"]+)"/);
|
|
|
|
|
const title = titleMatch ? titleMatch[1] : metadata.name;
|
|
|
|
|
description = `BMAD ${metadata.module.toUpperCase()} Agent: ${title}`;
|
|
|
|
|
globs = '';
|
|
|
|
|
} else if (isTask) {
|
|
|
|
|
// Extract task name if available
|
2025-10-26 19:38:38 -05:00
|
|
|
const nameMatch = content.match(/name="([^"]+)"/);
|
2025-09-28 23:17:07 -05:00
|
|
|
const taskName = nameMatch ? nameMatch[1] : metadata.name;
|
|
|
|
|
description = `BMAD ${metadata.module.toUpperCase()} Task: ${taskName}`;
|
2025-10-26 19:38:38 -05:00
|
|
|
globs = '';
|
|
|
|
|
} else if (isTool) {
|
|
|
|
|
// Extract tool name if available
|
|
|
|
|
const nameMatch = content.match(/name="([^"]+)"/);
|
|
|
|
|
const toolName = nameMatch ? nameMatch[1] : metadata.name;
|
|
|
|
|
description = `BMAD ${metadata.module.toUpperCase()} Tool: ${toolName}`;
|
|
|
|
|
globs = '';
|
|
|
|
|
} else if (isWorkflow) {
|
|
|
|
|
// Workflow
|
|
|
|
|
description = `BMAD ${metadata.module.toUpperCase()} Workflow: ${metadata.name}`;
|
2025-09-28 23:17:07 -05:00
|
|
|
globs = '';
|
|
|
|
|
} else {
|
|
|
|
|
description = `BMAD ${metadata.module.toUpperCase()}: ${metadata.name}`;
|
|
|
|
|
globs = '';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Create MDC metadata header
|
|
|
|
|
const mdcHeader = `---
|
|
|
|
|
description: ${description}
|
|
|
|
|
globs: ${globs}
|
|
|
|
|
alwaysApply: false
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
// Add the MDC header to the processed content
|
|
|
|
|
return mdcHeader + processed;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
module.exports = { CursorSetup };
|