remove uneeded files

This commit is contained in:
Brian Madison
2025-10-03 11:54:32 -05:00
parent 3f40ef4756
commit fd01ad69f8
7 changed files with 292 additions and 326 deletions

View File

@@ -333,7 +333,6 @@ class Installer {
// Pre-register manifest files that will be created (except files-manifest.csv to avoid recursion)
const cfgDir = path.join(bmadDir, '_cfg');
this.installedFiles.push(
path.join(cfgDir, 'manifest.csv'),
path.join(cfgDir, 'manifest.yaml'),
path.join(cfgDir, 'workflow-manifest.csv'),
path.join(cfgDir, 'agent-manifest.csv'),
@@ -419,21 +418,8 @@ class Installer {
spinner.succeed('Module-specific installers completed');
// Create manifest
spinner.start('Creating installation manifest...');
const manifestResult = await this.manifest.create(
bmadDir,
{
version: require(path.join(getProjectRoot(), 'package.json')).version,
installDate: new Date().toISOString(),
core: config.installCore,
modules: config.modules || [],
ides: config.ides || [],
language: config.language || null,
},
this.installedFiles,
);
spinner.succeed(`Manifest created (${manifestResult.filesTracked} files tracked)`);
// Note: Manifest files are already created by ManifestGenerator above
// No need to create legacy manifest.csv anymore
// If this was an update, restore custom files
let customFiles = [];
@@ -982,10 +968,13 @@ class Installer {
// Replace {project-root} placeholder
const processedContent = xmlContent.replaceAll('{project-root}', projectDir);
// Write the built .md file
// Write the built .md file to bmad/{module}/agents/
await fs.writeFile(mdPath, processedContent, 'utf8');
this.installedFiles.push(mdPath);
// Remove the source YAML file - we can regenerate from installer source if needed
await fs.remove(yamlPath);
console.log(chalk.dim(` Built agent: ${agentName}.md`));
}
// Handle legacy .md agents - inject activation if needed
@@ -1003,6 +992,100 @@ class Installer {
}
}
/**
* Rebuild agent files from installer source (for compile command)
* @param {string} modulePath - Path to module in bmad/ installation
* @param {string} moduleName - Module name
*/
async rebuildAgentFiles(modulePath, moduleName) {
// Get source agents directory from installer
const sourceAgentsPath =
moduleName === 'core' ? path.join(getModulePath('core'), 'agents') : path.join(getSourcePath(`modules/${moduleName}`), 'agents');
if (!(await fs.pathExists(sourceAgentsPath))) {
return; // No source agents to rebuild
}
// Determine project directory (parent of bmad/ directory)
const bmadDir = path.dirname(modulePath);
const projectDir = path.dirname(bmadDir);
const cfgAgentsDir = path.join(bmadDir, '_cfg', 'agents');
const targetAgentsPath = path.join(modulePath, 'agents');
// Ensure target directory exists
await fs.ensureDir(targetAgentsPath);
// Get all YAML agent files from source
const sourceFiles = await fs.readdir(sourceAgentsPath);
for (const file of sourceFiles) {
if (file.endsWith('.agent.yaml')) {
const agentName = file.replace('.agent.yaml', '');
const sourceYamlPath = path.join(sourceAgentsPath, file);
const targetMdPath = path.join(targetAgentsPath, `${agentName}.md`);
const customizePath = path.join(cfgAgentsDir, `${moduleName}-${agentName}.customize.yaml`);
// Check for customizations
const customizeExists = await fs.pathExists(customizePath);
let customizedFields = [];
if (customizeExists) {
const customizeContent = await fs.readFile(customizePath, 'utf8');
const yaml = require('js-yaml');
const customizeYaml = yaml.load(customizeContent);
// Detect what fields are customized
if (customizeYaml) {
if (customizeYaml.persona) {
for (const [key, value] of Object.entries(customizeYaml.persona)) {
if (value !== '' && value !== null && !(Array.isArray(value) && value.length === 0)) {
customizedFields.push(`persona.${key}`);
}
}
}
if (customizeYaml.agent?.metadata) {
for (const [key, value] of Object.entries(customizeYaml.agent.metadata)) {
if (value !== '' && value !== null) {
customizedFields.push(`metadata.${key}`);
}
}
}
if (customizeYaml.critical_actions && customizeYaml.critical_actions.length > 0) {
customizedFields.push('critical_actions');
}
if (customizeYaml.memories && customizeYaml.memories.length > 0) {
customizedFields.push('memories');
}
if (customizeYaml.menu && customizeYaml.menu.length > 0) {
customizedFields.push('menu');
}
if (customizeYaml.prompts && customizeYaml.prompts.length > 0) {
customizedFields.push('prompts');
}
}
}
// Build YAML + customize to .md
const xmlContent = await this.xmlHandler.buildFromYaml(sourceYamlPath, customizeExists ? customizePath : null, {
includeMetadata: true,
});
// Replace {project-root} placeholder
const processedContent = xmlContent.replaceAll('{project-root}', projectDir);
// Write the rebuilt .md file
await fs.writeFile(targetMdPath, processedContent, 'utf8');
// Display result with customizations if any
if (customizedFields.length > 0) {
console.log(chalk.dim(` Rebuilt agent: ${agentName}.md `) + chalk.yellow(`(customized: ${customizedFields.join(', ')})`));
} else {
console.log(chalk.dim(` Rebuilt agent: ${agentName}.md`));
}
}
}
}
/**
* Compile/rebuild all agents and tasks for quick updates
* @param {Object} config - Compilation configuration
@@ -1030,13 +1113,13 @@ class Installer {
const entries = await fs.readdir(bmadDir, { withFileTypes: true });
for (const entry of entries) {
if (entry.isDirectory() && entry.name !== '_cfg') {
if (entry.isDirectory() && entry.name !== '_cfg' && entry.name !== 'docs') {
const modulePath = path.join(bmadDir, entry.name);
// Process agents
// Rebuild agents from installer source
const agentsPath = path.join(modulePath, 'agents');
if (await fs.pathExists(agentsPath)) {
await this.processAgentFiles(modulePath, entry.name);
await this.rebuildAgentFiles(modulePath, entry.name);
const agentFiles = await fs.readdir(agentsPath);
agentCount += agentFiles.filter((f) => f.endsWith('.md')).length;
}

View File

@@ -146,22 +146,21 @@ class ManifestGenerator {
/**
* Collect all agents from core and selected modules
* Scans the INSTALLED bmad directory, not the source
*/
async collectAgents(selectedModules) {
this.agents = [];
// Get core agents
const corePath = getModulePath('core');
const coreAgentsPath = path.join(corePath, 'agents');
// Get core agents from installed bmad directory
const coreAgentsPath = path.join(this.bmadDir, 'core', 'agents');
if (await fs.pathExists(coreAgentsPath)) {
const coreAgents = await this.getAgentsFromDir(coreAgentsPath, 'core');
this.agents.push(...coreAgents);
}
// Get module agents
// Get module agents from installed bmad directory
for (const moduleName of selectedModules) {
const modulePath = getSourcePath(`modules/${moduleName}`);
const agentsPath = path.join(modulePath, 'agents');
const agentsPath = path.join(this.bmadDir, moduleName, 'agents');
if (await fs.pathExists(agentsPath)) {
const moduleAgents = await this.getAgentsFromDir(agentsPath, moduleName);
@@ -172,16 +171,23 @@ class ManifestGenerator {
/**
* Get agents from a directory
* Only includes compiled .md files (not .agent.yaml source files)
*/
async getAgentsFromDir(dirPath, moduleName) {
const agents = [];
const files = await fs.readdir(dirPath);
for (const file of files) {
if (file.endsWith('.md')) {
// Only include .md files, skip .agent.yaml source files and README.md
if (file.endsWith('.md') && !file.endsWith('.agent.yaml') && file.toLowerCase() !== 'readme.md') {
const filePath = path.join(dirPath, file);
const content = await fs.readFile(filePath, 'utf8');
// Skip files that don't contain <agent> tag (e.g., README files)
if (!content.includes('<agent')) {
continue;
}
// Skip web-only agents
if (content.includes('localskip="true"')) {
continue;
@@ -218,22 +224,21 @@ class ManifestGenerator {
/**
* Collect all tasks from core and selected modules
* Scans the INSTALLED bmad directory, not the source
*/
async collectTasks(selectedModules) {
this.tasks = [];
// Get core tasks
const corePath = getModulePath('core');
const coreTasksPath = path.join(corePath, 'tasks');
// Get core tasks from installed bmad directory
const coreTasksPath = path.join(this.bmadDir, 'core', 'tasks');
if (await fs.pathExists(coreTasksPath)) {
const coreTasks = await this.getTasksFromDir(coreTasksPath, 'core');
this.tasks.push(...coreTasks);
}
// Get module tasks
// Get module tasks from installed bmad directory
for (const moduleName of selectedModules) {
const modulePath = getSourcePath(`modules/${moduleName}`);
const tasksPath = path.join(modulePath, 'tasks');
const tasksPath = path.join(this.bmadDir, moduleName, 'tasks');
if (await fs.pathExists(tasksPath)) {
const moduleTasks = await this.getTasksFromDir(tasksPath, moduleName);
@@ -296,11 +301,7 @@ class ManifestGenerator {
installDate: new Date().toISOString(),
lastUpdated: new Date().toISOString(),
},
modules: this.modules.map((name) => ({
name,
version: '',
shortTitle: '',
})),
modules: this.modules,
ides: ['claude-code'],
};

View File

@@ -145,11 +145,6 @@ class YamlXmlBuilder {
let xml = '<!-- Powered by BMAD-CORE™ -->\n\n';
xml += `# ${metadata.title || 'Agent'}\n\n`;
// Add build metadata as comment
if (buildMetadata.includeMetadata) {
xml += this.buildMetadataComment(buildMetadata);
}
xml += '```xml\n';
// Agent opening tag