fix: yaml standardization in files and installer actions
This commit is contained in:
@@ -150,7 +150,7 @@ class WebBuilder {
|
||||
const agentName = parsed.agent?.id || "agent";
|
||||
|
||||
// Build the new content with just the agent header and YAML
|
||||
const newHeader = `# ${agentName}\n\nCRITICAL: Read the full YML, start activation to alter your state of being, follow startup section instructions, stay in this being until told to exit this mode:\n\n`;
|
||||
const newHeader = `# ${agentName}\n\nCRITICAL: Read the full YAML, start activation to alter your state of being, follow startup section instructions, stay in this being until told to exit this mode:\n\n`;
|
||||
const afterYaml = content.substring(yamlEndIndex);
|
||||
|
||||
return newHeader + "```yaml\n" + cleanedYaml.trim() + "\n```" + afterYaml;
|
||||
|
||||
@@ -98,7 +98,7 @@ class IdeSetup {
|
||||
)} agent persona.\n\n`;
|
||||
mdcContent += "## Agent Activation\n\n";
|
||||
mdcContent +=
|
||||
"CRITICAL: Read the full YML, start activation to alter your state of being, follow startup section instructions, stay in this being until told to exit this mode:\n\n";
|
||||
"CRITICAL: Read the full YAML, start activation to alter your state of being, follow startup section instructions, stay in this being until told to exit this mode:\n\n";
|
||||
mdcContent += "```yaml\n";
|
||||
// Extract just the YAML content from the agent file
|
||||
const yamlContent = extractYamlFromAgent(agentContent);
|
||||
@@ -116,7 +116,7 @@ class IdeSetup {
|
||||
mdcContent += `When the user types \`@${agentId}\`, activate this ${await this.getAgentTitle(
|
||||
agentId,
|
||||
installDir
|
||||
)} persona and follow all instructions defined in the YML configuration above.\n`;
|
||||
)} persona and follow all instructions defined in the YAML configuration above.\n`;
|
||||
|
||||
await fileManager.writeFile(mdcPath, mdcContent);
|
||||
console.log(chalk.green(`✓ Created rule: ${agentId}.mdc`));
|
||||
@@ -180,7 +180,7 @@ class IdeSetup {
|
||||
)} agent persona.\n\n`;
|
||||
mdContent += "## Agent Activation\n\n";
|
||||
mdContent +=
|
||||
"CRITICAL: Read the full YML, start activation to alter your state of being, follow startup section instructions, stay in this being until told to exit this mode:\n\n";
|
||||
"CRITICAL: Read the full YAML, start activation to alter your state of being, follow startup section instructions, stay in this being until told to exit this mode:\n\n";
|
||||
mdContent += "```yaml\n";
|
||||
// Extract just the YAML content from the agent file
|
||||
const yamlContent = extractYamlFromAgent(agentContent);
|
||||
@@ -198,7 +198,7 @@ class IdeSetup {
|
||||
mdContent += `When the user types \`@${agentId}\`, activate this ${await this.getAgentTitle(
|
||||
agentId,
|
||||
installDir
|
||||
)} persona and follow all instructions defined in the YML configuration above.\n`;
|
||||
)} persona and follow all instructions defined in the YAML configuration above.\n`;
|
||||
|
||||
await fileManager.writeFile(mdPath, mdContent);
|
||||
console.log(chalk.green(`✓ Created rule: ${agentId}.md`));
|
||||
@@ -362,7 +362,7 @@ class IdeSetup {
|
||||
newModesContent += ` whenToUse: ${whenToUse}\n`;
|
||||
// Get relative path from installDir to agent file
|
||||
const relativePath = path.relative(installDir, agentPath).replace(/\\/g, '/');
|
||||
newModesContent += ` customInstructions: CRITICAL Read the full YML from ${relativePath} start activation to alter your state of being follow startup section instructions stay in this being until told to exit this mode\n`;
|
||||
newModesContent += ` customInstructions: CRITICAL Read the full YAML from ${relativePath} start activation to alter your state of being follow startup section instructions stay in this being until told to exit this mode\n`;
|
||||
newModesContent += ` groups:\n`;
|
||||
newModesContent += ` - read\n`;
|
||||
|
||||
|
||||
@@ -685,6 +685,10 @@ class Installer {
|
||||
};
|
||||
|
||||
await this.performFreshInstall(config, installDir, spinner, { isUpdate: true });
|
||||
|
||||
// Clean up .yml files that now have .yaml counterparts
|
||||
spinner.text = "Cleaning up legacy .yml files...";
|
||||
await this.cleanupLegacyYmlFiles(installDir, spinner);
|
||||
} catch (error) {
|
||||
spinner.fail("Update failed");
|
||||
throw error;
|
||||
@@ -737,12 +741,27 @@ class Installer {
|
||||
if (await fileManager.pathExists(sourcePath)) {
|
||||
await fileManager.copyFile(sourcePath, destPath);
|
||||
spinner.text = `Restored: ${file}`;
|
||||
|
||||
// If this is a .yaml file, check for and remove corresponding .yml file
|
||||
if (file.endsWith('.yaml')) {
|
||||
const ymlFile = file.replace(/\.yaml$/, '.yml');
|
||||
const ymlPath = path.join(installDir, ymlFile);
|
||||
if (await fileManager.pathExists(ymlPath)) {
|
||||
const fs = require('fs').promises;
|
||||
await fs.unlink(ymlPath);
|
||||
console.log(chalk.dim(` Removed legacy: ${ymlFile} (replaced by ${file})`));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
console.warn(chalk.yellow(` Warning: Source file not found: ${file}`));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Clean up .yml files that now have .yaml counterparts
|
||||
spinner.text = "Cleaning up legacy .yml files...";
|
||||
await this.cleanupLegacyYmlFiles(installDir, spinner);
|
||||
|
||||
spinner.succeed("Repair completed successfully!");
|
||||
|
||||
// Show summary
|
||||
@@ -778,7 +797,13 @@ class Installer {
|
||||
}
|
||||
|
||||
spinner.text = "Installing fresh copy...";
|
||||
return await this.performFreshInstall(config, installDir, spinner, { isUpdate: true });
|
||||
const result = await this.performFreshInstall(config, installDir, spinner, { isUpdate: true });
|
||||
|
||||
// Clean up .yml files that now have .yaml counterparts
|
||||
spinner.text = "Cleaning up legacy .yml files...";
|
||||
await this.cleanupLegacyYmlFiles(installDir, spinner);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
showSuccessMessage(config, installDir, options = {}) {
|
||||
@@ -1637,6 +1662,42 @@ class Installer {
|
||||
return 0;
|
||||
}
|
||||
|
||||
async cleanupLegacyYmlFiles(installDir, spinner) {
|
||||
const glob = require('glob');
|
||||
const fs = require('fs').promises;
|
||||
|
||||
try {
|
||||
// Find all .yml files in the installation directory
|
||||
const ymlFiles = glob.sync('**/*.yml', {
|
||||
cwd: installDir,
|
||||
ignore: ['**/node_modules/**', '**/.git/**']
|
||||
});
|
||||
|
||||
let deletedCount = 0;
|
||||
|
||||
for (const ymlFile of ymlFiles) {
|
||||
// Check if corresponding .yaml file exists
|
||||
const yamlFile = ymlFile.replace(/\.yml$/, '.yaml');
|
||||
const ymlPath = path.join(installDir, ymlFile);
|
||||
const yamlPath = path.join(installDir, yamlFile);
|
||||
|
||||
if (await fileManager.pathExists(yamlPath)) {
|
||||
// .yaml counterpart exists, delete the .yml file
|
||||
await fs.unlink(ymlPath);
|
||||
deletedCount++;
|
||||
console.log(chalk.dim(` Removed legacy: ${ymlFile} (replaced by ${yamlFile})`));
|
||||
}
|
||||
}
|
||||
|
||||
if (deletedCount > 0) {
|
||||
console.log(chalk.green(`✓ Cleaned up ${deletedCount} legacy .yml files`));
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
console.warn(chalk.yellow(`Warning: Could not cleanup legacy .yml files: ${error.message}`));
|
||||
}
|
||||
}
|
||||
|
||||
async findInstallation() {
|
||||
// Look for .bmad-core in current directory or parent directories
|
||||
let currentDir = process.cwd();
|
||||
|
||||
Reference in New Issue
Block a user