diff --git a/tools/cli/installers/lib/core/installer.js b/tools/cli/installers/lib/core/installer.js index 4512cd6d..5d3b0033 100644 --- a/tools/cli/installers/lib/core/installer.js +++ b/tools/cli/installers/lib/core/installer.js @@ -1599,10 +1599,15 @@ If AgentVibes party mode is enabled, immediately trigger TTS with agent's voice: const sourceModulePath = getSourcePath(`modules/${moduleName}`); const sourceAgentPath = path.join(sourceModulePath, 'agents'); - // Copy sidecar files - const sidecarFiles = copyAgentSidecarFiles(sourceAgentPath, agentSidecarDir, yamlPath); + // Copy sidecar files (preserve existing, add new) + const sidecarResult = copyAgentSidecarFiles(sourceAgentPath, agentSidecarDir, yamlPath); - console.log(chalk.dim(` Copied sidecar to: ${agentSidecarDir}`)); + if (sidecarResult.copied.length > 0) { + console.log(chalk.dim(` Copied ${sidecarResult.copied.length} new sidecar file(s) to: ${agentSidecarDir}`)); + } + if (sidecarResult.preserved.length > 0) { + console.log(chalk.dim(` Preserved ${sidecarResult.preserved.length} existing sidecar file(s)`)); + } } // Remove the source YAML file - we can regenerate from installer source if needed @@ -2645,8 +2650,12 @@ If AgentVibes party mode is enabled, immediately trigger TTS with agent's voice: const agentSidecarDir = path.join(resolvedSidecarFolder, finalAgentName); await fs.ensureDir(agentSidecarDir); - // Find and copy sidecar folder - const sidecarFiles = copyAgentSidecarFiles(agent.path, agentSidecarDir, agent.yamlFile); + // Copy sidecar files (preserve existing, add new) + const sidecarResult = copyAgentSidecarFiles(agent.path, agentSidecarDir, agent.yamlFile); + + if (sidecarResult.copied.length > 0 || sidecarResult.preserved.length > 0) { + console.log(chalk.dim(` Sidecar: ${sidecarResult.copied.length} new, ${sidecarResult.preserved.length} preserved`)); + } } // Update manifest CSV diff --git a/tools/cli/installers/lib/modules/manager.js b/tools/cli/installers/lib/modules/manager.js index 70e07f6a..b9252370 100644 --- a/tools/cli/installers/lib/modules/manager.js +++ b/tools/cli/installers/lib/modules/manager.js @@ -750,10 +750,16 @@ class ModuleManager { const agentSidecarDir = path.join(resolvedSidecarFolder, agentName); await fs.ensureDir(agentSidecarDir); - // Copy sidecar files - const sidecarFiles = copyAgentSidecarFiles(path.dirname(sourceYamlPath), agentSidecarDir, sourceYamlPath); + // Copy sidecar files (preserve existing, add new) + const sidecarResult = copyAgentSidecarFiles(path.dirname(sourceYamlPath), agentSidecarDir, sourceYamlPath); + const totalFiles = sidecarResult.copied.length + sidecarResult.preserved.length; - console.log(chalk.dim(` Copied sidecar to: ${agentSidecarDir}`)); + if (sidecarResult.copied.length > 0) { + console.log(chalk.dim(` Copied ${sidecarResult.copied.length} new sidecar file(s) to: ${agentSidecarDir}`)); + } + if (sidecarResult.preserved.length > 0) { + console.log(chalk.dim(` Preserved ${sidecarResult.preserved.length} existing sidecar file(s)`)); + } } console.log( diff --git a/tools/cli/lib/agent/installer.js b/tools/cli/lib/agent/installer.js index 9f11b588..d79abd23 100644 --- a/tools/cli/lib/agent/installer.js +++ b/tools/cli/lib/agent/installer.js @@ -337,6 +337,7 @@ function copySidecarFiles(sourceDir, targetDir, excludeYaml) { */ function copyAgentSidecarFiles(sourceDir, targetSidecarDir, excludeYaml) { const copied = []; + const preserved = []; // Find folders with "sidecar" in the name const entries = fs.readdirSync(sourceDir, { withFileTypes: true }); @@ -345,31 +346,42 @@ function copyAgentSidecarFiles(sourceDir, targetSidecarDir, excludeYaml) { if (entry.isDirectory() && entry.name.toLowerCase().includes('sidecar')) { const sidecarSourcePath = path.join(sourceDir, entry.name); - // Recursively copy the sidecar folder contents - function copySidecarDir(src, dest) { + // Recursively sync the sidecar folder contents (preserve existing, add new) + function syncSidecarDir(src, dest) { if (!fs.existsSync(dest)) { fs.mkdirSync(dest, { recursive: true }); } - const sidecarEntries = fs.readdirSync(src, { withFileTypes: true }); - for (const sidecarEntry of sidecarEntries) { - const srcPath = path.join(src, sidecarEntry.name); - const destPath = path.join(dest, sidecarEntry.name); + // Get all files in source + const sourceEntries = fs.readdirSync(src, { withFileTypes: true }); - if (sidecarEntry.isDirectory()) { - copySidecarDir(srcPath, destPath); + for (const sourceEntry of sourceEntries) { + const srcPath = path.join(src, sourceEntry.name); + const destPath = path.join(dest, sourceEntry.name); + + if (sourceEntry.isDirectory()) { + // Recursively sync subdirectories + syncSidecarDir(srcPath, destPath); } else { - fs.copyFileSync(srcPath, destPath); - copied.push(destPath); + // Check if file already exists in destination + if (fs.existsSync(destPath)) { + // File exists - preserve it + preserved.push(destPath); + } else { + // File doesn't exist - copy it + fs.copyFileSync(srcPath, destPath); + copied.push(destPath); + } } } } - copySidecarDir(sidecarSourcePath, targetSidecarDir); + syncSidecarDir(sidecarSourcePath, targetSidecarDir); } } - return copied; + // Return info about what was preserved and what was copied + return { copied, preserved }; } /**