Skip to content

Commit e62513c

Browse files
committed
Update for CI failures
1 parent 83887fb commit e62513c

File tree

2 files changed

+21
-11
lines changed

2 files changed

+21
-11
lines changed

claude-config-composer/src/generator/config-generator.ts

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -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-z0-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-z0-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);

claude-config-composer/src/utils/path-validator.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -293,14 +293,12 @@ export class PathValidator {
293293
const fullPath = path.join(fullDirectory, validatedFilename);
294294

295295
// Double-check using path operations that don't require process.cwd()
296-
const normalizedBase = path.normalize(basePath);
297296
const normalizedTarget = path.normalize(fullPath);
298297

299-
// Check if target escapes base using relative path
300-
const relativePath = path.relative(normalizedBase, normalizedTarget);
301-
// Normalize separators for consistent checking across platforms
302-
const normalizedRelative = relativePath.replace(/\\/g, '/');
303-
if (normalizedRelative.startsWith('..')) {
298+
// Check if target escapes base without using path.relative()
299+
// which can call process.cwd() and fail in CI
300+
// Simply ensure the path doesn't contain .. after normalization
301+
if (normalizedTarget.includes('..')) {
304302
throw new PathValidationError(
305303
'Resolved file path escapes base directory',
306304
`${directory}/${filename}`

0 commit comments

Comments
 (0)