From 34cfdddd3aa19945e8ff342d6eec7e51dca8ca62 Mon Sep 17 00:00:00 2001 From: Brian Madison Date: Mon, 22 Dec 2025 13:12:25 +0800 Subject: [PATCH] refac tools part 1 --- tools/cli/installers/lib/core/installer.js | 72 +++++++++------------ tools/cli/installers/lib/ide/_base-ide.js | 5 -- tools/cli/installers/lib/modules/manager.js | 2 +- tools/cli/lib/agent-party-generator.js | 2 +- tools/cli/lib/agent/xml-handler.js | 7 -- tools/cli/lib/agent/yaml-xml-builder.js | 2 +- tools/{ => cli}/lib/xml-utils.js | 0 tools/flattener/xml.js | 2 +- 8 files changed, 36 insertions(+), 56 deletions(-) rename tools/{ => cli}/lib/xml-utils.js (100%) diff --git a/tools/cli/installers/lib/core/installer.js b/tools/cli/installers/lib/core/installer.js index 8e6f5a4b..50f06d1c 100644 --- a/tools/cli/installers/lib/core/installer.js +++ b/tools/cli/installers/lib/core/installer.js @@ -297,49 +297,41 @@ class Installer { console.log('\n'); // Add spacing before IDE questions for (const ide of newlySelectedIdes) { - // List of IDEs that have interactive prompts - //TODO: Why is this here, hardcoding this list here is bad, fix me! - const needsPrompts = ['claude-code', 'github-copilot', 'roo', 'cline', 'auggie', 'codex', 'qwen', 'gemini', 'rovo-dev'].includes( - ide, - ); + // Get IDE handler and check if it needs interactive configuration + try { + // Dynamically load the IDE setup module + const ideModule = require(`../ide/${ide}`); - if (needsPrompts) { - // Get IDE handler and collect configuration - try { - // Dynamically load the IDE setup module - const ideModule = require(`../ide/${ide}`); + // Get the setup class (handle different export formats) + let SetupClass; + const className = + ide + .split('-') + .map((part) => part.charAt(0).toUpperCase() + part.slice(1)) + .join('') + 'Setup'; - // Get the setup class (handle different export formats) - let SetupClass; - const className = - ide - .split('-') - .map((part) => part.charAt(0).toUpperCase() + part.slice(1)) - .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}`)); + 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 (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}`)); } } } diff --git a/tools/cli/installers/lib/ide/_base-ide.js b/tools/cli/installers/lib/ide/_base-ide.js index 1aedceb7..bfa9af88 100644 --- a/tools/cli/installers/lib/ide/_base-ide.js +++ b/tools/cli/installers/lib/ide/_base-ide.js @@ -493,11 +493,6 @@ class BaseIdeSetup { // Replace placeholders let processed = content; - // Inject activation block for agent files FIRST (before replacements) - if (metadata.name && content.includes('