mirror of
https://github.com/bmadcode/BMAD-METHOD.git
synced 2025-12-29 16:14:59 +00:00
agents now are not duplicated and isntead cli commmands load from installed agent files
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
const path = require('node:path');
|
||||
const { BaseIdeSetup } = require('./_base-ide');
|
||||
const chalk = require('chalk');
|
||||
const { AgentCommandGenerator } = require('./shared/agent-command-generator');
|
||||
|
||||
/**
|
||||
* Cursor IDE setup handler
|
||||
@@ -45,8 +46,14 @@ class CursorSetup extends BaseIdeSetup {
|
||||
|
||||
await this.ensureDir(bmadRulesDir);
|
||||
|
||||
// Get agents, tasks, tools, and workflows (standalone only)
|
||||
const agents = await this.getAgents(bmadDir);
|
||||
// Generate agent launchers first
|
||||
const agentGen = new AgentCommandGenerator(this.bmadFolderName);
|
||||
const { artifacts: agentArtifacts } = await agentGen.collectAgentArtifacts(bmadDir, options.selectedModules || []);
|
||||
|
||||
// Convert artifacts to agent format for index creation
|
||||
const agents = agentArtifacts.map((a) => ({ module: a.module, name: a.name }));
|
||||
|
||||
// Get tasks, tools, and workflows (standalone only)
|
||||
const tasks = await this.getTasks(bmadDir, true);
|
||||
const tools = await this.getTools(bmadDir, true);
|
||||
const workflows = await this.getWorkflows(bmadDir, true);
|
||||
@@ -63,15 +70,16 @@ class CursorSetup extends BaseIdeSetup {
|
||||
await this.ensureDir(path.join(bmadRulesDir, module, 'workflows'));
|
||||
}
|
||||
|
||||
// Process and copy agents
|
||||
// Process and write agent launchers with MDC format
|
||||
let agentCount = 0;
|
||||
for (const agent of agents) {
|
||||
const content = await this.readAndProcess(agent.path, {
|
||||
module: agent.module,
|
||||
name: agent.name,
|
||||
for (const artifact of agentArtifacts) {
|
||||
// Add MDC metadata header to launcher (but don't call processContent which adds activation headers)
|
||||
const content = this.wrapLauncherWithMDC(artifact.content, {
|
||||
module: artifact.module,
|
||||
name: artifact.name,
|
||||
});
|
||||
|
||||
const targetPath = path.join(bmadRulesDir, agent.module, 'agents', `${agent.name}.mdc`);
|
||||
const targetPath = path.join(bmadRulesDir, artifact.module, 'agents', `${artifact.name}.mdc`);
|
||||
|
||||
await this.writeFile(targetPath, content);
|
||||
agentCount++;
|
||||
@@ -311,6 +319,34 @@ alwaysApply: false
|
||||
// Add the MDC header to the processed content
|
||||
return mdcHeader + processed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrap launcher content with MDC metadata (without base processing)
|
||||
* Launchers are already complete and should not have activation headers injected
|
||||
*/
|
||||
wrapLauncherWithMDC(launcherContent, metadata = {}) {
|
||||
// Strip the launcher's frontmatter - we'll replace it with MDC frontmatter
|
||||
const frontmatterRegex = /^---\s*\n[\s\S]*?\n---\s*\n/;
|
||||
const contentWithoutFrontmatter = launcherContent.replace(frontmatterRegex, '');
|
||||
|
||||
// Extract metadata from launcher frontmatter for MDC description
|
||||
const nameMatch = launcherContent.match(/name:\s*"([^"]+)"/);
|
||||
const name = nameMatch ? nameMatch[1] : metadata.name;
|
||||
|
||||
const description = `BMAD ${metadata.module.toUpperCase()} Agent: ${name}`;
|
||||
|
||||
// Create MDC metadata header
|
||||
const mdcHeader = `---
|
||||
description: ${description}
|
||||
globs:
|
||||
alwaysApply: false
|
||||
---
|
||||
|
||||
`;
|
||||
|
||||
// Return MDC header + launcher content (without its original frontmatter)
|
||||
return mdcHeader + contentWithoutFrontmatter;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { CursorSetup };
|
||||
|
||||
Reference in New Issue
Block a user