Skip to content

Commit 85bff1c

Browse files
committed
fix: include global mode rules files in export
- Fix exportModeWithRules to check correct rules directory based on mode source - For global modes, check global .roo directory instead of workspace directory - For project modes, continue checking workspace .roo directory - Fixes issue where global mode exports were missing rules files Fixes #5834
1 parent d2b51c1 commit 85bff1c

File tree

1 file changed

+26
-9
lines changed

1 file changed

+26
-9
lines changed

src/core/config/CustomModesManager.ts

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -687,15 +687,21 @@ 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 correct rules directory based on mode source
691+
let modeRulesDir: string
692+
if (mode.source === "global") {
693+
// For global modes, check the global .roo directory
694+
const globalRooDir = getGlobalRooDirectory()
695+
modeRulesDir = path.join(globalRooDir, `rules-${slug}`)
696+
} else {
697+
// For project modes, check the workspace .roo directory
698+
const workspacePath = getWorkspacePath()
699+
if (!workspacePath) {
700+
return { success: false, error: "No workspace found" }
701+
}
702+
modeRulesDir = path.join(workspacePath, ".roo", `rules-${slug}`)
694703
}
695704

696-
// Check for .roo/rules-{slug}/ directory
697-
const modeRulesDir = path.join(workspacePath, ".roo", `rules-${slug}`)
698-
699705
let rulesFiles: RuleFile[] = []
700706
try {
701707
const stats = await fs.stat(modeRulesDir)
@@ -709,8 +715,19 @@ export class CustomModesManager {
709715
const filePath = path.join(modeRulesDir, entry.name)
710716
const content = await fs.readFile(filePath, "utf-8")
711717
if (content.trim()) {
712-
// Calculate relative path from .roo directory
713-
const relativePath = path.relative(path.join(workspacePath, ".roo"), filePath)
718+
// Calculate relative path from .roo directory based on mode source
719+
let relativePath: string
720+
if (mode.source === "global") {
721+
const globalRooDir = getGlobalRooDirectory()
722+
relativePath = path.relative(globalRooDir, filePath)
723+
} else {
724+
const workspacePath = getWorkspacePath()
725+
if (workspacePath) {
726+
relativePath = path.relative(path.join(workspacePath, ".roo"), filePath)
727+
} else {
728+
relativePath = path.relative(".", filePath)
729+
}
730+
}
714731
rulesFiles.push({ relativePath, content: content.trim() })
715732
}
716733
}

0 commit comments

Comments
 (0)