refac tools part 1

This commit is contained in:
Brian Madison 2025-12-22 13:12:25 +08:00
parent 1e721f7fd0
commit 34cfdddd3a
8 changed files with 36 additions and 56 deletions

View File

@ -297,49 +297,41 @@ class Installer {
console.log('\n'); // Add spacing before IDE questions console.log('\n'); // Add spacing before IDE questions
for (const ide of newlySelectedIdes) { for (const ide of newlySelectedIdes) {
// List of IDEs that have interactive prompts // Get IDE handler and check if it needs interactive configuration
//TODO: Why is this here, hardcoding this list here is bad, fix me! try {
const needsPrompts = ['claude-code', 'github-copilot', 'roo', 'cline', 'auggie', 'codex', 'qwen', 'gemini', 'rovo-dev'].includes( // Dynamically load the IDE setup module
ide, const ideModule = require(`../ide/${ide}`);
);
if (needsPrompts) { // Get the setup class (handle different export formats)
// Get IDE handler and collect configuration let SetupClass;
try { const className =
// Dynamically load the IDE setup module ide
const ideModule = require(`../ide/${ide}`); .split('-')
.map((part) => part.charAt(0).toUpperCase() + part.slice(1))
.join('') + 'Setup';
// Get the setup class (handle different export formats) if (ideModule[className]) {
let SetupClass; SetupClass = ideModule[className];
const className = } else if (ideModule.default) {
ide SetupClass = ideModule.default;
.split('-') } else {
.map((part) => part.charAt(0).toUpperCase() + part.slice(1)) continue;
.join('') + 'Setup';
if (ideModule[className]) {
SetupClass = ideModule[className];
} else if (ideModule.default) {
SetupClass = ideModule.default;
} else {
continue;
}
const ideSetup = new SetupClass();
// Check if this IDE has a collectConfiguration method
if (typeof ideSetup.collectConfiguration === 'function') {
console.log(chalk.cyan(`\nConfiguring ${ide}...`));
ideConfigurations[ide] = await ideSetup.collectConfiguration({
selectedModules: selectedModules || [],
projectDir,
bmadDir,
});
}
} catch {
// IDE doesn't have a setup file or collectConfiguration method
console.warn(chalk.yellow(`Warning: Could not load configuration for ${ide}`));
} }
const ideSetup = new SetupClass();
// Check if this IDE has a collectConfiguration method (no hardcoding needed!)
if (typeof ideSetup.collectConfiguration === 'function') {
console.log(chalk.cyan(`\nConfiguring ${ide}...`));
ideConfigurations[ide] = await ideSetup.collectConfiguration({
selectedModules: selectedModules || [],
projectDir,
bmadDir,
});
}
} catch {
// IDE doesn't have a setup file or collectConfiguration method
console.warn(chalk.yellow(`Warning: Could not load configuration for ${ide}`));
} }
} }
} }

View File

@ -493,11 +493,6 @@ class BaseIdeSetup {
// Replace placeholders // Replace placeholders
let processed = content; let processed = content;
// Inject activation block for agent files FIRST (before replacements)
if (metadata.name && content.includes('<agent')) {
processed = this.xmlHandler.injectActivationSimple(processed, metadata);
}
// Only replace {project-root} if a specific projectDir is provided // Only replace {project-root} if a specific projectDir is provided
// Otherwise leave the placeholder intact // Otherwise leave the placeholder intact
// Note: Don't add trailing slash - paths in source include leading slash // Note: Don't add trailing slash - paths in source include leading slash

View File

@ -952,7 +952,7 @@ class ModuleManager {
// // Check if content has agent XML and no activation block // // Check if content has agent XML and no activation block
// if (content.includes('<agent') && !content.includes('<activation')) { // if (content.includes('<agent') && !content.includes('<activation')) {
// // Inject the activation block using XML handler // // Inject the activation block using XML handler
// content = this.xmlHandler.injectActivationSimple(content); // // TODO: Reimplement activation injection if needed
// await fs.writeFile(agentFile, content, 'utf8'); // await fs.writeFile(agentFile, content, 'utf8');
// } // }
// } // }

View File

@ -1,6 +1,6 @@
const path = require('node:path'); const path = require('node:path');
const fs = require('fs-extra'); const fs = require('fs-extra');
const { escapeXml } = require('../../lib/xml-utils'); const { escapeXml } = require('./xml-utils');
const AgentPartyGenerator = { const AgentPartyGenerator = {
/** /**

View File

@ -124,13 +124,6 @@ class XmlHandler {
} }
} }
/**
* TODO: DELETE THIS METHOD
*/
injectActivationSimple(agentContent, metadata = {}) {
console.error('Error in simple injection:', error);
}
/** /**
* Build agent from YAML source * Build agent from YAML source
* @param {string} yamlPath - Path to .agent.yaml file * @param {string} yamlPath - Path to .agent.yaml file

View File

@ -4,7 +4,7 @@ const path = require('node:path');
const crypto = require('node:crypto'); const crypto = require('node:crypto');
const { AgentAnalyzer } = require('./agent-analyzer'); const { AgentAnalyzer } = require('./agent-analyzer');
const { ActivationBuilder } = require('./activation-builder'); const { ActivationBuilder } = require('./activation-builder');
const { escapeXml } = require('../../../lib/xml-utils'); const { escapeXml } = require('../xml-utils');
const { const {
processAgentYaml, processAgentYaml,
extractInstallConfig, extractInstallConfig,

View File

@ -1,5 +1,5 @@
const fs = require('fs-extra'); const fs = require('fs-extra');
const { escapeXml } = require('../lib/xml-utils'); const { escapeXml } = require('../cli/lib/xml-utils');
function indentFileContent(content) { function indentFileContent(content) {
if (typeof content !== 'string') { if (typeof content !== 'string') {