Skip to content

Commit 68e5f0b

Browse files
committed
refactor: rename .roo/roo_modes to .roo/modes for cleaner directory structure
- Changed ROO_MODES_DIR constant from "roo_modes" to "modes" - Updated all references in CustomModesManager.ts - Updated all test descriptions and mocks in CustomModesManager.spec.ts - All tests passing successfully
1 parent a571a78 commit 68e5f0b

File tree

2 files changed

+31
-31
lines changed

2 files changed

+31
-31
lines changed

src/core/config/CustomModesManager.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import { ensureSettingsDirectoryExists } from "../../utils/globalContext"
1717
import { t } from "../../i18n"
1818

1919
const ROOMODES_FILENAME = ".roomodes"
20-
const ROO_MODES_DIR = "roo_modes"
20+
const ROO_MODES_DIR = "modes"
2121

2222
// Type definitions for import/export functionality
2323
interface RuleFile {
@@ -323,7 +323,7 @@ export class CustomModesManager {
323323
this.disposables.push(settingsWatcher.onDidDelete(handleModeFileChange))
324324
this.disposables.push(settingsWatcher)
325325

326-
// Watch global .roo/roo_modes directory
326+
// Watch global .roo/modes directory
327327
const globalRooModesDir = path.join(getGlobalRooDirectory(), ROO_MODES_DIR)
328328
const globalRooModesPattern = path.join(globalRooModesDir, "*.{yaml,yml}")
329329
const globalRooModesWatcher = vscode.workspace.createFileSystemWatcher(globalRooModesPattern)
@@ -332,7 +332,7 @@ export class CustomModesManager {
332332
this.disposables.push(globalRooModesWatcher.onDidDelete(handleModeFileChange))
333333
this.disposables.push(globalRooModesWatcher)
334334

335-
// Watch .roomodes file and project .roo/roo_modes directory if workspace exists
335+
// Watch .roomodes file and project .roo/modes directory if workspace exists
336336
const workspaceFolders = vscode.workspace.workspaceFolders
337337
if (workspaceFolders && workspaceFolders.length > 0) {
338338
const workspaceRoot = getWorkspacePath()
@@ -345,7 +345,7 @@ export class CustomModesManager {
345345
this.disposables.push(roomodesWatcher.onDidDelete(handleModeFileChange))
346346
this.disposables.push(roomodesWatcher)
347347

348-
// Watch project .roo/roo_modes directory
348+
// Watch project .roo/modes directory
349349
const projectRooModesDir = path.join(workspaceRoot, ".roo", ROO_MODES_DIR)
350350
const projectRooModesPattern = path.join(projectRooModesDir, "*.{yaml,yml}")
351351
const projectRooModesWatcher = vscode.workspace.createFileSystemWatcher(projectRooModesPattern)
@@ -368,15 +368,15 @@ export class CustomModesManager {
368368
const settingsPath = await this.getCustomModesFilePath()
369369
const settingsModes = await this.loadModesFromFile(settingsPath, "global")
370370

371-
// Get modes from .roo/roo_modes directories (both global and project)
371+
// Get modes from .roo/modes directories (both global and project)
372372
const allRooModesDirModes: ModeConfig[] = []
373373

374-
// Load from global .roo/roo_modes
374+
// Load from global .roo/modes
375375
const globalRooModesDir = path.join(getGlobalRooDirectory(), ROO_MODES_DIR)
376376
const globalRooModesDirModes = await this.loadModesFromDirectory(globalRooModesDir, "global")
377377
allRooModesDirModes.push(...globalRooModesDirModes)
378378

379-
// Load from project .roo/roo_modes if workspace exists
379+
// Load from project .roo/modes if workspace exists
380380
const workspacePath = getWorkspacePath()
381381
if (workspacePath) {
382382
const projectRooModesDir = path.join(workspacePath, ".roo", ROO_MODES_DIR)
@@ -390,9 +390,9 @@ export class CustomModesManager {
390390

391391
// Create a map to store modes with proper precedence
392392
// Precedence order (highest to lowest):
393-
// 1. .roo/roo_modes (project)
393+
// 1. .roo/modes (project)
394394
// 2. .roomodes (project)
395-
// 3. .roo/roo_modes (global)
395+
// 3. .roo/modes (global)
396396
// 4. settings file (global)
397397
const modesMap = new Map<string, ModeConfig>()
398398

@@ -402,7 +402,7 @@ export class CustomModesManager {
402402
modesMap.set(mode.slug, mode)
403403
}
404404

405-
// 3. Global .roo/roo_modes
405+
// 3. Global .roo/modes
406406
for (const mode of globalRooModesDirModes) {
407407
modesMap.set(mode.slug, mode)
408408
}
@@ -412,7 +412,7 @@ export class CustomModesManager {
412412
modesMap.set(mode.slug, mode)
413413
}
414414

415-
// 1. Project .roo/roo_modes (highest precedence)
415+
// 1. Project .roo/modes (highest precedence)
416416
for (const mode of allRooModesDirModes.filter((m) => m.source === "project")) {
417417
modesMap.set(mode.slug, mode)
418418
}
@@ -586,7 +586,7 @@ export class CustomModesManager {
586586
}
587587
}
588588

589-
// Check and delete from .roo/roo_modes directories
589+
// Check and delete from .roo/modes directories
590590
const rooDirectories = getRooDirectoriesForCwd(getWorkspacePath() || process.cwd())
591591
for (const rooDir of rooDirectories) {
592592
const rooModesDir = path.join(rooDir, ROO_MODES_DIR)

src/core/config/__tests__/CustomModesManager.spec.ts

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -114,17 +114,17 @@ describe("CustomModesManager", () => {
114114
expect(modes).toHaveLength(2)
115115
})
116116

117-
it("should load modes from .roo/roo_modes directory", async () => {
117+
it("should load modes from .roo/modes directory", async () => {
118118
const settingsModes = [{ slug: "mode1", name: "Mode 1", roleDefinition: "Role 1", groups: ["read"] }]
119119
const rooModesMode1 = { slug: "mode2", name: "Mode 2", roleDefinition: "Role 2", groups: ["read"] }
120120
const rooModesMode2 = { slug: "mode3", name: "Mode 3", roleDefinition: "Role 3", groups: ["edit"] }
121121

122122
;(fileExistsAtPath as Mock).mockImplementation(async (path: string) => {
123-
// Return true for settings path and roo_modes directories
124-
return path === mockSettingsPath || path.includes("roo_modes") || path === mockRoomodes
123+
// Return true for settings path and modes directories
124+
return path === mockSettingsPath || path.includes("modes") || path === mockRoomodes
125125
})
126126
;(fs.readdir as Mock).mockImplementation(async (path: string) => {
127-
if (path.includes("roo_modes")) {
127+
if (path.includes("modes")) {
128128
return [
129129
{ name: "mode1.yaml", isFile: () => true },
130130
{ name: "mode2.yml", isFile: () => true },
@@ -155,7 +155,7 @@ describe("CustomModesManager", () => {
155155
expect(modes.map((m) => m.slug)).toContain("mode3")
156156
})
157157

158-
it("should respect precedence: project .roo/roo_modes > .roomodes > global .roo/roo_modes > settings", async () => {
158+
it("should respect precedence: project .roo/modes > .roomodes > global .roo/modes > settings", async () => {
159159
const settingsMode = { slug: "test", name: "Settings", roleDefinition: "Settings Role", groups: ["read"] }
160160
const globalRooMode = {
161161
slug: "test",
@@ -175,7 +175,7 @@ describe("CustomModesManager", () => {
175175
return true // All paths exist
176176
})
177177
;(fs.readdir as Mock).mockImplementation(async (path: string) => {
178-
if (path.includes("roo_modes")) {
178+
if (path.includes("modes")) {
179179
return [{ name: "test.yaml", isFile: () => true }]
180180
}
181181
return []
@@ -187,12 +187,12 @@ describe("CustomModesManager", () => {
187187
if (path === mockRoomodes) {
188188
return yaml.stringify({ customModes: [roomodesMode] })
189189
}
190-
// Global .roo/roo_modes
191-
if (path.includes("roo_modes") && !path.includes(mockWorkspacePath)) {
190+
// Global .roo/modes
191+
if (path.includes("modes") && !path.includes(mockWorkspacePath)) {
192192
return yaml.stringify({ customModes: [globalRooMode] })
193193
}
194-
// Project .roo/roo_modes
195-
if (path.includes("roo_modes") && path.includes(mockWorkspacePath)) {
194+
// Project .roo/modes
195+
if (path.includes("modes") && path.includes(mockWorkspacePath)) {
196196
return yaml.stringify({ customModes: [projectRooMode] })
197197
}
198198
throw new Error("File not found")
@@ -202,16 +202,16 @@ describe("CustomModesManager", () => {
202202

203203
// Should have only one mode with the slug "test"
204204
expect(modes).toHaveLength(1)
205-
// Project .roo/roo_modes should take precedence
205+
// Project .roo/modes should take precedence
206206
expect(modes[0].name).toBe("Project Roo")
207207
expect(modes[0].roleDefinition).toBe("Project Roo Role")
208208
})
209209

210-
it("should handle empty .roo/roo_modes directory", async () => {
210+
it("should handle empty .roo/modes directory", async () => {
211211
const settingsModes = [{ slug: "mode1", name: "Mode 1", roleDefinition: "Role 1", groups: ["read"] }]
212212

213213
;(fileExistsAtPath as Mock).mockImplementation(async (path: string) => {
214-
return path === mockSettingsPath || path.includes("roo_modes")
214+
return path === mockSettingsPath || path.includes("modes")
215215
})
216216
;(fs.readdir as Mock).mockImplementation(async () => {
217217
return [] // Empty directory
@@ -230,12 +230,12 @@ describe("CustomModesManager", () => {
230230
expect(modes[0].slug).toBe("mode1")
231231
})
232232

233-
it("should handle non-existent .roo/roo_modes directory", async () => {
233+
it("should handle non-existent .roo/modes directory", async () => {
234234
const settingsModes = [{ slug: "mode1", name: "Mode 1", roleDefinition: "Role 1", groups: ["read"] }]
235235

236236
;(fileExistsAtPath as Mock).mockImplementation(async (path: string) => {
237-
// roo_modes directories don't exist
238-
if (path.includes("roo_modes")) {
237+
// modes directories don't exist
238+
if (path.includes("modes")) {
239239
return false
240240
}
241241
return path === mockSettingsPath
@@ -254,14 +254,14 @@ describe("CustomModesManager", () => {
254254
expect(modes[0].slug).toBe("mode1")
255255
})
256256

257-
it("should preserve sourceFile property for modes loaded from .roo/roo_modes", async () => {
257+
it("should preserve sourceFile property for modes loaded from .roo/modes", async () => {
258258
const rooModesMode = { slug: "test", name: "Test Mode", roleDefinition: "Test Role", groups: ["read"] }
259259

260260
;(fileExistsAtPath as Mock).mockImplementation(async (path: string) => {
261-
return path === mockSettingsPath || path.includes("roo_modes")
261+
return path === mockSettingsPath || path.includes("modes")
262262
})
263263
;(fs.readdir as Mock).mockImplementation(async (path: string) => {
264-
if (path.includes("roo_modes")) {
264+
if (path.includes("modes")) {
265265
return [{ name: "test.yaml", isFile: () => true }]
266266
}
267267
return []

0 commit comments

Comments
 (0)