Skip to content

Commit 02c3f5a

Browse files
committed
fix: resolve global mode export not including rules files (#5834)
- Modified exportModeWithRules to check correct directory based on mode source - For global modes, now uses getGlobalRooDirectory() to access ~/.roo - For project modes, continues to use workspace directory - Adjusted rules directory path construction for global vs project modes - Updated relative path calculation to handle different directory structures This ensures global mode rules files from ~/.roo/rules-{slug}/ are correctly included when exporting global modes.
1 parent d2b51c1 commit 02c3f5a

File tree

1 file changed

+22
-8
lines changed

1 file changed

+22
-8
lines changed

src/core/config/CustomModesManager.ts

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -687,14 +687,25 @@ export class CustomModesManager {
687687
}
688688
}
689689

690-
// Get workspace path
691-
const workspacePath = getWorkspacePath()
692-
if (!workspacePath) {
693-
return { success: false, error: "No workspace found" }
690+
// Determine the base directory based on mode source
691+
let baseDir: string
692+
if (mode.source === "global") {
693+
// For global modes, use the global .roo directory
694+
baseDir = getGlobalRooDirectory()
695+
} else {
696+
// For project modes, use the workspace directory
697+
const workspacePath = getWorkspacePath()
698+
if (!workspacePath) {
699+
return { success: false, error: "No workspace found" }
700+
}
701+
baseDir = workspacePath
694702
}
695703

696-
// Check for .roo/rules-{slug}/ directory
697-
const modeRulesDir = path.join(workspacePath, ".roo", `rules-${slug}`)
704+
// Check for .roo/rules-{slug}/ directory (or rules-{slug}/ for global)
705+
const modeRulesDir =
706+
mode.source === "global"
707+
? path.join(baseDir, `rules-${slug}`)
708+
: path.join(baseDir, ".roo", `rules-${slug}`)
698709

699710
let rulesFiles: RuleFile[] = []
700711
try {
@@ -709,8 +720,11 @@ export class CustomModesManager {
709720
const filePath = path.join(modeRulesDir, entry.name)
710721
const content = await fs.readFile(filePath, "utf-8")
711722
if (content.trim()) {
712-
// Calculate relative path from .roo directory
713-
const relativePath = path.relative(path.join(workspacePath, ".roo"), filePath)
723+
// Calculate relative path based on mode source
724+
const relativePath =
725+
mode.source === "global"
726+
? path.relative(baseDir, filePath)
727+
: path.relative(path.join(baseDir, ".roo"), filePath)
714728
rulesFiles.push({ relativePath, content: content.trim() })
715729
}
716730
}

0 commit comments

Comments
 (0)