refactor: simplify module discovery to scan entire project

- Module discovery now scans entire project recursively for install-config.yaml
- Removed hardcoded module locations (bmad-custom-src, etc.)
- Modules can exist anywhere with _module-installer/install-config.yaml
- All modules treated equally regardless of location
- No special UI handling for 'custom' modules
- Core module excluded from selection list (always installed first)
- Only install-config.yaml is valid (removed support for legacy config.yaml)

Modules are now discovered by structure, not location.
This commit is contained in:
Brian Madison
2025-12-06 15:28:37 -06:00
parent 7c5c97a914
commit 0d83799ecf
7 changed files with 243 additions and 1285 deletions

View File

@@ -182,14 +182,24 @@ class ConfigCollector {
}
// Load module's install config schema
const installerConfigPath = path.join(getModulePath(moduleName), '_module-installer', 'install-config.yaml');
const legacyConfigPath = path.join(getModulePath(moduleName), 'config.yaml');
// First, try the standard src/modules location
let installerConfigPath = path.join(getModulePath(moduleName), '_module-installer', 'install-config.yaml');
// If not found in src/modules, we need to find it by searching the project
if (!(await fs.pathExists(installerConfigPath))) {
// Use the module manager to find the module source
const { ModuleManager } = require('../modules/manager');
const moduleManager = new ModuleManager();
const moduleSourcePath = await moduleManager.findModuleSource(moduleName);
if (moduleSourcePath) {
installerConfigPath = path.join(moduleSourcePath, '_module-installer', 'install-config.yaml');
}
}
let configPath = null;
if (await fs.pathExists(installerConfigPath)) {
configPath = installerConfigPath;
} else if (await fs.pathExists(legacyConfigPath)) {
configPath = legacyConfigPath;
} else {
// No config schema for this module - use existing values
if (this.existingConfig && this.existingConfig[moduleName]) {
@@ -396,32 +406,25 @@ class ConfigCollector {
if (!this.allAnswers) {
this.allAnswers = {};
}
// Load module's config.yaml (check custom modules first, then regular modules)
let installerConfigPath;
let legacyConfigPath;
// Load module's config
// First, try the standard src/modules location
let installerConfigPath = path.join(getModulePath(moduleName), '_module-installer', 'install-config.yaml');
if (moduleName.startsWith('custom-')) {
// Handle custom modules
const actualModuleName = moduleName.replace('custom-', '');
// If not found in src/modules, we need to find it by searching the project
if (!(await fs.pathExists(installerConfigPath))) {
// Use the module manager to find the module source
const { ModuleManager } = require('../modules/manager');
const moduleManager = new ModuleManager();
const moduleSourcePath = await moduleManager.findModuleSource(moduleName);
// Custom modules are in the BMAD-METHOD source directory, not the installation directory
const bmadMethodRoot = getProjectRoot(); // This gets the BMAD-METHOD root
const customSrcPath = path.join(bmadMethodRoot, 'bmad-custom-src', 'modules', actualModuleName);
installerConfigPath = path.join(customSrcPath, '_module-installer', 'install-config.yaml');
legacyConfigPath = path.join(customSrcPath, 'config.yaml');
console.log(chalk.dim(`[DEBUG] Looking for custom module config in: ${installerConfigPath}`));
} else {
// Regular modules
installerConfigPath = path.join(getModulePath(moduleName), '_module-installer', 'install-config.yaml');
legacyConfigPath = path.join(getModulePath(moduleName), 'config.yaml');
if (moduleSourcePath) {
installerConfigPath = path.join(moduleSourcePath, '_module-installer', 'install-config.yaml');
}
}
let configPath = null;
if (await fs.pathExists(installerConfigPath)) {
configPath = installerConfigPath;
} else if (await fs.pathExists(legacyConfigPath)) {
configPath = legacyConfigPath;
} else {
// No config for this module
return;

View File

@@ -418,7 +418,7 @@ If AgentVibes party mode is enabled, immediately trigger TTS with agent's voice:
const projectDir = path.resolve(config.directory);
// If core config was pre-collected (from interactive mode), use it
if (config.coreConfig && !this.configCollector.collectedConfig.core) {
if (config.coreConfig) {
this.configCollector.collectedConfig.core = config.coreConfig;
// Also store in allAnswers for cross-referencing
this.configCollector.allAnswers = {};
@@ -427,16 +427,11 @@ If AgentVibes party mode is enabled, immediately trigger TTS with agent's voice:
}
}
// Collect configurations for modules (skip if quick update already collected them or if pre-collected)
// Collect configurations for modules (skip if quick update already collected them)
let moduleConfigs;
if (config._quickUpdate) {
// Quick update already collected all configs, use them directly
moduleConfigs = this.configCollector.collectedConfig;
} else if (config.moduleConfig) {
// Use pre-collected configs from UI (includes custom modules)
moduleConfigs = config.moduleConfig;
// Also need to load them into configCollector for later use
this.configCollector.collectedConfig = moduleConfigs;
} else {
// Regular install - collect configurations (core was already collected in UI.promptInstall if interactive)
moduleConfigs = await this.configCollector.collectAllConfigurations(config.modules || [], path.resolve(config.directory));
@@ -753,14 +748,13 @@ If AgentVibes party mode is enabled, immediately trigger TTS with agent's voice:
spinner.text = 'Creating directory structure...';
await this.createDirectoryStructure(bmadDir);
// Resolve dependencies for selected modules (skip custom modules)
// Resolve dependencies for selected modules
spinner.text = 'Resolving dependencies...';
const projectRoot = getProjectRoot();
const regularModules = (config.modules || []).filter((m) => !m.startsWith('custom-'));
const modulesToInstall = config.installCore ? ['core', ...regularModules] : regularModules;
const modulesToInstall = config.installCore ? ['core', ...config.modules] : config.modules;
// For dependency resolution, we need to pass the project root
const resolution = await this.dependencyResolver.resolve(projectRoot, regularModules, { verbose: config.verbose });
const resolution = await this.dependencyResolver.resolve(projectRoot, config.modules || [], { verbose: config.verbose });
if (config.verbose) {
spinner.succeed('Dependencies resolved');
@@ -775,17 +769,17 @@ If AgentVibes party mode is enabled, immediately trigger TTS with agent's voice:
spinner.succeed('Core installed');
}
// Install modules with their dependencies (skip custom modules - they're handled by install.js)
if (regularModules.length > 0) {
for (const moduleName of regularModules) {
// Install modules with their dependencies
if (config.modules && config.modules.length > 0) {
for (const moduleName of config.modules) {
spinner.start(`Installing module: ${moduleName}...`);
await this.installModuleWithDependencies(moduleName, bmadDir, resolution.byModule[moduleName]);
spinner.succeed(`Module installed: ${moduleName}`);
}
// Install partial modules (only dependencies) - skip custom modules
// Install partial modules (only dependencies)
for (const [module, files] of Object.entries(resolution.byModule)) {
if (!regularModules.includes(module) && module !== 'core') {
if (!config.modules.includes(module) && module !== 'core') {
const totalFiles =
files.agents.length +
files.tasks.length +