Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions cmd/bundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -328,24 +328,31 @@ func installPromptFiles(bundleRoot, projectRoot string, promptFiles []string, fo
}

for _, pf := range promptFiles {
normalizedPath := strings.TrimPrefix(pf, "prompts/")
normalizedPath = strings.TrimPrefix(normalizedPath, "/")

if normalizedPath == "" {
return nil, fmt.Errorf("invalid prompt path in config: %q - path cannot be empty after normalization", pf)
}

sourcePath := filepath.Join(bundleRoot, pf)

// Verify source file exists
if _, err := os.Stat(sourcePath); err != nil {
return nil, fmt.Errorf("prompt file not found in bundle: %s", pf)
}

// Determine destination (preserve relative structure)
destPath := filepath.Join(promptsDir, filepath.Base(pf))
// Determine destination (preserve relative structure, but strip leading "prompts/" prefix)
destPath := filepath.Join(promptsDir, filepath.Base(normalizedPath))

// Create subdirectory if needed (for paths like prompts/subdir/file.md)
if strings.Contains(pf, string(filepath.Separator)) {
subdir := filepath.Dir(pf)
// Create subdirectory if needed (for paths like subdir/file.md)
if strings.Contains(normalizedPath, string(filepath.Separator)) {
subdir := filepath.Dir(normalizedPath)
subdirPath := filepath.Join(promptsDir, subdir)
if err := os.MkdirAll(subdirPath, 0755); err != nil {
return nil, fmt.Errorf("failed to create subdirectory: %w", err)
}
destPath = filepath.Join(promptsDir, pf)
destPath = filepath.Join(promptsDir, normalizedPath)
}

// Check if destination exists (unless force)
Expand Down
Loading