fix(installer): resolve module source before reading marketplace version

Move _readMarketplaceVersion call after source type resolution so custom
modules use their own source path instead of falling back to the external
module cache, which could match a different module with the same code.
This commit is contained in:
Brian Madison 2026-04-07 02:18:23 -05:00
parent 3c155e3cbc
commit baea8652b9
1 changed files with 8 additions and 6 deletions

View File

@ -837,14 +837,11 @@ class Manifest {
* @returns {Object} Version info object with version, source, npmPackage, repoUrl * @returns {Object} Version info object with version, source, npmPackage, repoUrl
*/ */
async getModuleVersionInfo(moduleName, bmadDir, moduleSourcePath = null) { async getModuleVersionInfo(moduleName, bmadDir, moduleSourcePath = null) {
const os = require('node:os');
const yaml = require('yaml'); const yaml = require('yaml');
// All module versions come from .claude-plugin/marketplace.json // Resolve source type first, then read version with the correct path context
const version = await this._readMarketplaceVersion(moduleName, moduleSourcePath);
// Determine source type
if (['core', 'bmm'].includes(moduleName)) { if (['core', 'bmm'].includes(moduleName)) {
const version = await this._readMarketplaceVersion(moduleName, moduleSourcePath);
return { return {
version, version,
source: 'built-in', source: 'built-in',
@ -859,6 +856,8 @@ class Manifest {
const moduleInfo = await extMgr.getModuleByCode(moduleName); const moduleInfo = await extMgr.getModuleByCode(moduleName);
if (moduleInfo) { if (moduleInfo) {
// External module: use moduleSourcePath if provided, otherwise fall back to cache
const version = await this._readMarketplaceVersion(moduleName, moduleSourcePath);
return { return {
version, version,
source: 'external', source: 'external',
@ -867,7 +866,10 @@ class Manifest {
}; };
} }
// Custom module - check cache directory // Custom module: resolve path from source or cache before reading version
const customSourcePath = moduleSourcePath || path.join(bmadDir, '_config', 'custom', moduleName);
const version = await this._readMarketplaceVersion(moduleName, customSourcePath);
const cacheDir = path.join(bmadDir, '_config', 'custom', moduleName); const cacheDir = path.join(bmadDir, '_config', 'custom', moduleName);
const moduleYamlPath = path.join(cacheDir, 'module.yaml'); const moduleYamlPath = path.join(cacheDir, 'module.yaml');