fix: nested agents now appear in CLI commands

- Fix getAgentsFromDir in bmad-artifacts.js to recursively scan subdirectories
- This ensures agents like cbt-coach and wellness-companion that are in subdirectories are properly found
- Agents now correctly get slash commands in .claude/commands/bmad/mwm/agents/
- All agents from the manifest now have corresponding IDE commands
This commit is contained in:
Brian Madison
2025-12-06 16:39:28 -06:00
parent 86e2daabba
commit 74d071708d
2 changed files with 36 additions and 33 deletions

View File

@@ -83,39 +83,42 @@ async function getAgentsFromDir(dirPath, moduleName) {
return agents;
}
const files = await fs.readdir(dirPath);
const entries = await fs.readdir(dirPath, { withFileTypes: true });
for (const file of files) {
if (!file.endsWith('.md')) {
continue;
for (const entry of entries) {
const fullPath = path.join(dirPath, entry.name);
if (entry.isDirectory()) {
// Recurse into subdirectories
const subDirAgents = await getAgentsFromDir(fullPath, moduleName);
agents.push(...subDirAgents);
} else if (entry.name.endsWith('.md')) {
// Skip README files and other non-agent files
if (entry.name.toLowerCase() === 'readme.md' || entry.name.toLowerCase().startsWith('readme-')) {
continue;
}
if (entry.name.includes('.customize.')) {
continue;
}
const content = await fs.readFile(fullPath, 'utf8');
if (content.includes('localskip="true"')) {
continue;
}
// Only include files that have agent-specific content (compiled agents have <agent> tag)
if (!content.includes('<agent')) {
continue;
}
agents.push({
path: fullPath,
name: entry.name.replace('.md', ''),
module: moduleName,
});
}
// Skip README files and other non-agent files
if (file.toLowerCase() === 'readme.md' || file.toLowerCase().startsWith('readme-')) {
continue;
}
if (file.includes('.customize.')) {
continue;
}
const filePath = path.join(dirPath, file);
const content = await fs.readFile(filePath, 'utf8');
if (content.includes('localskip="true"')) {
continue;
}
// Only include files that have agent-specific content (compiled agents have <agent> tag)
if (!content.includes('<agent')) {
continue;
}
agents.push({
path: filePath,
name: file.replace('.md', ''),
module: moduleName,
});
}
return agents;