@@ -262,129 +262,11 @@ function installAgent(agentInfo, answers, targetPath, options = {}) {
262262 agentName : metadata . name || agentInfo . name ,
263263 targetDir : agentTargetDir ,
264264 compiledFile : compiledPath ,
265- sidecarCopied : false ,
266265 } ;
267266
268- // Handle sidecar files for agents with hasSidecar flag
269- if ( agentInfo . hasSidecar === true && agentInfo . type === 'expert' ) {
270- // Get agent sidecar folder from config or use default
271- const agentSidecarFolder = options . config ?. agent_sidecar_folder || '{project-root}/.myagent-data' ;
272-
273- // Resolve path variables
274- const resolvedSidecarFolder = agentSidecarFolder
275- . replaceAll ( '{project-root}' , options . projectRoot || process . cwd ( ) )
276- . replaceAll ( '_bmad' , options_bmadFolder || '_bmad' ) ;
277-
278- // Create sidecar directory for this agent
279- const agentSidecarDir = path . join ( resolvedSidecarFolder , agentFolderName ) ;
280- if ( ! fs . existsSync ( agentSidecarDir ) ) {
281- fs . mkdirSync ( agentSidecarDir , { recursive : true } ) ;
282- }
283-
284- // Find and copy sidecar folder
285- const sidecarFiles = copyAgentSidecarFiles ( agentInfo . path , agentSidecarDir , agentInfo . yamlFile ) ;
286- result . sidecarCopied = true ;
287- result . sidecarFiles = sidecarFiles ;
288- result . sidecarDir = agentSidecarDir ;
289- }
290-
291267 return result ;
292268}
293269
294- /**
295- * Recursively copy sidecar files (everything except the .agent.yaml)
296- * @param {string } sourceDir - Source agent directory
297- * @param {string } targetDir - Target agent directory
298- * @param {string } excludeYaml - The .agent.yaml file to exclude
299- * @returns {Array } List of copied files
300- */
301- function copySidecarFiles ( sourceDir , targetDir , excludeYaml ) {
302- const copied = [ ] ;
303-
304- function copyDir ( src , dest ) {
305- if ( ! fs . existsSync ( dest ) ) {
306- fs . mkdirSync ( dest , { recursive : true } ) ;
307- }
308-
309- const entries = fs . readdirSync ( src , { withFileTypes : true } ) ;
310- for ( const entry of entries ) {
311- const srcPath = path . join ( src , entry . name ) ;
312- const destPath = path . join ( dest , entry . name ) ;
313-
314- // Skip the source YAML file
315- if ( srcPath === excludeYaml ) {
316- continue ;
317- }
318-
319- if ( entry . isDirectory ( ) ) {
320- copyDir ( srcPath , destPath ) ;
321- } else {
322- fs . copyFileSync ( srcPath , destPath ) ;
323- copied . push ( destPath ) ;
324- }
325- }
326- }
327-
328- copyDir ( sourceDir , targetDir ) ;
329- return copied ;
330- }
331-
332- /**
333- * Find and copy agent sidecar folders
334- * @param {string } sourceDir - Source agent directory
335- * @param {string } targetSidecarDir - Target sidecar directory for the agent
336- * @param {string } excludeYaml - The .agent.yaml file to exclude
337- * @returns {Array } List of copied files
338- */
339- function copyAgentSidecarFiles ( sourceDir , targetSidecarDir , excludeYaml ) {
340- const copied = [ ] ;
341- const preserved = [ ] ;
342-
343- // Find folders with "sidecar" in the name
344- const entries = fs . readdirSync ( sourceDir , { withFileTypes : true } ) ;
345-
346- for ( const entry of entries ) {
347- if ( entry . isDirectory ( ) && entry . name . toLowerCase ( ) . includes ( 'sidecar' ) ) {
348- const sidecarSourcePath = path . join ( sourceDir , entry . name ) ;
349-
350- // Recursively sync the sidecar folder contents (preserve existing, add new)
351- function syncSidecarDir ( src , dest ) {
352- if ( ! fs . existsSync ( dest ) ) {
353- fs . mkdirSync ( dest , { recursive : true } ) ;
354- }
355-
356- // Get all files in source
357- const sourceEntries = fs . readdirSync ( src , { withFileTypes : true } ) ;
358-
359- for ( const sourceEntry of sourceEntries ) {
360- const srcPath = path . join ( src , sourceEntry . name ) ;
361- const destPath = path . join ( dest , sourceEntry . name ) ;
362-
363- if ( sourceEntry . isDirectory ( ) ) {
364- // Recursively sync subdirectories
365- syncSidecarDir ( srcPath , destPath ) ;
366- } else {
367- // Check if file already exists in destination
368- if ( fs . existsSync ( destPath ) ) {
369- // File exists - preserve it
370- preserved . push ( destPath ) ;
371- } else {
372- // File doesn't exist - copy it
373- fs . copyFileSync ( srcPath , destPath ) ;
374- copied . push ( destPath ) ;
375- }
376- }
377- }
378- }
379-
380- syncSidecarDir ( sidecarSourcePath , targetSidecarDir ) ;
381- }
382- }
383-
384- // Return info about what was preserved and what was copied
385- return { copied, preserved } ;
386- }
387-
388270/**
389271 * Update agent metadata ID to reflect installed location
390272 * @param {string } compiledContent - Compiled XML content
@@ -820,8 +702,6 @@ module.exports = {
820702 loadAgentConfig,
821703 promptInstallQuestions,
822704 installAgent,
823- copySidecarFiles,
824- copyAgentSidecarFiles,
825705 updateAgentId,
826706 detectBmadProject,
827707 addToManifest,
0 commit comments