fix: Clear all npm config env vars before calling AgentVibes installer

When BMAD is invoked with --prefix flag, npm sets many npm_config_*
and npm_package_* environment variables. These caused npx agentvibes
to look for files in the wrong directory (/prefix/lib instead of cwd).

Changes:
- tools/cli/commands/install.js: Filter out ALL npm_config_* and
  npm_package_* env vars before calling npx agentvibes
- tools/cli/installers/lib/core/installer.js: Add AgentVibes prompt
  to Quick Update flow so existing installations can enable TTS
- tools/cli/installers/lib/core/manifest-generator.js: Track
  agentVibes configuration in manifest.yaml

This ensures AgentVibes runs in a clean environment regardless of
how BMAD was invoked (with or without --prefix flag).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Paul Preibisch 2025-11-27 09:46:16 -07:00
parent e3f756488a
commit d9b10490b4
3 changed files with 45 additions and 0 deletions

View File

@ -90,10 +90,18 @@ module.exports = {
// Run AgentVibes installer
const { execSync } = require('node:child_process');
try {
// Clear ALL npm config env vars to prevent inheritance issues
// when BMAD is invoked with --prefix flag
// npm sets many npm_config_* and npm_package_* vars that can interfere
const cleanEnv = Object.fromEntries(
Object.entries(process.env).filter(([key]) => !key.startsWith('npm_config_') && !key.startsWith('npm_package_')),
);
execSync('npx agentvibes@latest install', {
cwd: result.projectDir,
stdio: 'inherit',
shell: true,
env: cleanEnv,
});
console.log(chalk.green('\n✓ AgentVibes installation complete'));
} catch {

View File

@ -824,6 +824,7 @@ If AgentVibes party mode is enabled, immediately trigger TTS with agent's voice:
const manifestStats = await manifestGen.generateManifests(bmadDir, config.modules || [], this.installedFiles, {
ides: config.ides || [],
preservedModules: config._preserveModules || [], // Scan these from installed bmad/ dir
agentVibes: { enabled: this.enableAgentVibes || false }, // Track AgentVibes TTS configuration
});
spinner.succeed(
@ -1966,6 +1967,37 @@ If AgentVibes party mode is enabled, immediately trigger TTS with agent's voice:
}
}
// Check for AgentVibes TTS - prompt if not previously configured
// Read existing manifest to check if AgentVibes was previously set
const manifestPath = path.join(bmadDir, '_cfg', 'manifest.yaml');
let agentVibesEnabled = false;
let agentVibesPreviouslyConfigured = false;
try {
const manifestContent = await fs.readFile(manifestPath, 'utf8');
const yaml = require('js-yaml');
const manifest = yaml.load(manifestContent);
// Check if AgentVibes was previously configured (exists in manifest)
if (manifest.agentVibes !== undefined) {
agentVibesPreviouslyConfigured = true;
agentVibesEnabled = manifest.agentVibes?.enabled || false;
}
} catch {
// Manifest doesn't exist or can't be read - treat as not configured
}
// If AgentVibes wasn't previously configured, prompt the user
if (!agentVibesPreviouslyConfigured) {
const { UI } = require('../../../lib/ui');
const ui = new UI();
const agentVibesConfig = await ui.promptAgentVibes(projectDir);
if (agentVibesConfig.enableTts) {
agentVibesEnabled = true;
promptedForNewFields = true;
}
}
if (!promptedForNewFields) {
console.log(chalk.green('✓ All configuration is up to date, no new options to configure'));
}
@ -2003,6 +2035,7 @@ If AgentVibes party mode is enabled, immediately trigger TTS with agent's voice:
_quickUpdate: true, // Flag to skip certain prompts
_preserveModules: skippedModules, // Preserve these in manifest even though we didn't update them
_savedIdeConfigs: savedIdeConfigs, // Pass saved IDE configs to installer
enableAgentVibes: agentVibesEnabled, // AgentVibes TTS configuration
};
// Call the standard install method

View File

@ -54,6 +54,9 @@ class ManifestGenerator {
// Filter out any undefined/null values from IDE list
this.selectedIdes = resolvedIdes.filter((ide) => ide && typeof ide === 'string');
// Store AgentVibes configuration for manifest
this.agentVibes = options.agentVibes || null;
// Collect workflow data
await this.collectWorkflows(selectedModules);
@ -446,6 +449,7 @@ class ManifestGenerator {
},
modules: this.modules,
ides: this.selectedIdes,
agentVibes: this.agentVibes, // Track AgentVibes TTS configuration
};
const yamlStr = yaml.dump(manifest, {