From 4fd7bba8f027006f8a579553aa8a69b92d0b6a3c Mon Sep 17 00:00:00 2001 From: hunter6028 <58544242+hunter6028@users.noreply.github.com> Date: Mon, 24 Nov 2025 19:24:00 +0800 Subject: [PATCH] Fix: Support custom module agent compilation in rebuildAgentFiles() - Check module's own agents directory first for custom modules - Fall back to installer source for built-in modules - Fixes custom module agent compilation issue in alpha versions This change enables rebuildAgentFiles() to properly compile agents from custom modules by first checking the module's own agents/ directory for .agent.yaml files. If found, it uses those files directly. Otherwise, it falls back to the installer source directory for built-in modules (core, bmm, bmb, etc.). Tested with custom module 'po' (Prompt Optimizer) - agents compile successfully and slash commands are generated correctly. --- tools/cli/installers/lib/core/installer.js | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/tools/cli/installers/lib/core/installer.js b/tools/cli/installers/lib/core/installer.js index 63a1db20..562e4678 100644 --- a/tools/cli/installers/lib/core/installer.js +++ b/tools/cli/installers/lib/core/installer.js @@ -1466,12 +1466,24 @@ class Installer { * @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'); + // First try module's own agents directory (for custom modules) + let sourceAgentsPath = path.join(modulePath, 'agents'); - if (!(await fs.pathExists(sourceAgentsPath))) { - return; // No source agents to rebuild + // Check if module has its own .agent.yaml files + let hasOwnAgents = false; + if (await fs.pathExists(sourceAgentsPath)) { + const files = await fs.readdir(sourceAgentsPath); + hasOwnAgents = files.some(f => f.endsWith('.agent.yaml')); + } + + // If no agents in module directory, try installer source (for built-in modules) + if (!hasOwnAgents) { + 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)