@@ -93,12 +93,18 @@ export class ConfigGenerator {
9393 commandsDir = path . join ( outputDir , '.claude' , 'commands' ) ;
9494 hooksDir = path . join ( outputDir , '.claude' , 'hooks' ) ;
9595 } else {
96- // For relative paths, use createSafeDirectory for validation
97- claudeDir = await PathValidator . createSafeDirectory ( '.claude' , outputDir ) ;
98- agentsDir = await PathValidator . createSafeDirectory ( '.claude/agents ' , outputDir ) ;
99- commandsDir = await PathValidator . createSafeDirectory ( '.claude/commands ' , outputDir ) ;
100- hooksDir = await PathValidator . createSafeDirectory ( '.claude/hooks ' , outputDir ) ;
96+ // For relative paths, construct the full paths
97+ claudeDir = path . join ( outputDir , '.claude' ) ;
98+ agentsDir = path . join ( outputDir , '.claude' , 'agents' ) ;
99+ commandsDir = path . join ( outputDir , '.claude' , 'commands' ) ;
100+ hooksDir = path . join ( outputDir , '.claude' , 'hooks' ) ;
101101 }
102+
103+ // Create all directories
104+ await fs . mkdir ( claudeDir , { recursive : true } ) ;
105+ await fs . mkdir ( agentsDir , { recursive : true } ) ;
106+ await fs . mkdir ( commandsDir , { recursive : true } ) ;
107+ await fs . mkdir ( hooksDir , { recursive : true } ) ;
102108
103109 await fs . mkdir ( outputDir , { recursive : true } ) ;
104110 await fs . mkdir ( claudeDir , { recursive : true } ) ;
@@ -138,6 +144,8 @@ export class ConfigGenerator {
138144 const agentName = typeof validatedAgent . name === 'string' ? validatedAgent . name : 'unknown' ;
139145 const filename = `${ PathValidator . validateFilename ( agentName . toLowerCase ( ) . replace ( / [ ^ a - z 0 - 9 - ] / g, '-' ) ) } .md` ;
140146 const content = this . componentMerger . generateAgentFile ( validatedAgent ) ;
147+ // Ensure directory exists before writing
148+ await fs . mkdir ( agentsDir , { recursive : true } ) ;
141149 // Write directly to agentsDir
142150 const agentPath = path . join ( agentsDir , filename ) ;
143151 await fs . writeFile ( agentPath , content ) ;
@@ -158,6 +166,8 @@ export class ConfigGenerator {
158166 typeof validatedCommand . name === 'string' ? validatedCommand . name : 'unknown' ;
159167 const filename = `${ PathValidator . validateFilename ( commandName . toLowerCase ( ) . replace ( / [ ^ a - z 0 - 9 - ] / g, '-' ) ) } .md` ;
160168 const content = this . componentMerger . generateCommandFile ( validatedCommand ) ;
169+ // Ensure directory exists before writing
170+ await fs . mkdir ( commandsDir , { recursive : true } ) ;
161171 // Write directly to commandsDir
162172 const commandPath = path . join ( commandsDir , filename ) ;
163173 await fs . writeFile ( commandPath , content ) ;
@@ -171,6 +181,8 @@ export class ConfigGenerator {
171181 const hookGroups = parsedConfigs . map ( c => c . parsed . hooks ) ;
172182 const mergedHooks = this . componentMerger . mergeHooks ( hookGroups ) ;
173183
184+ // Ensure hooks directory exists
185+ await fs . mkdir ( hooksDir , { recursive : true } ) ;
174186 for ( const hook of mergedHooks ) {
175187 // Validate and sanitize hook data
176188 const validatedHook = InputValidator . validateHook ( hook ) ;
0 commit comments