Skip to content

Commit 71047ab

Browse files
committed
fix: revert dot file exclusion, rely on existing .swp blacklist instead
- Removed the general dot file exclusion that was filtering all hidden files - Updated test to focus specifically on .swp files rather than all dot files - The existing blacklist already includes *.swp and *.swo patterns which handles Vim swap files - This approach is more targeted and avoids excluding potentially useful dot files
1 parent 6687320 commit 71047ab

File tree

2 files changed

+14
-25
lines changed

2 files changed

+14
-25
lines changed

src/core/prompts/sections/__tests__/custom-instructions.spec.ts

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -321,20 +321,19 @@ describe("loadRuleFiles", () => {
321321
}
322322
})
323323

324-
it("should filter out Vim swap files and other dot files from .roo/rules/ directory", async () => {
324+
it("should filter out Vim swap files from .roo/rules/ directory", async () => {
325325
// Simulate .roo/rules directory exists
326326
statMock.mockResolvedValueOnce({
327327
isDirectory: vi.fn().mockReturnValue(true),
328328
} as any)
329329

330-
// Simulate listing files including Vim swap files and other dot files
330+
// Simulate listing files including Vim swap files
331331
readdirMock.mockResolvedValueOnce([
332332
{ name: "rule1.txt", isFile: () => true, isSymbolicLink: () => false, parentPath: "/fake/path/.roo/rules" },
333333
{ name: ".01-prettier-tree-sitter.md.swp", isFile: () => true, isSymbolicLink: () => false, parentPath: "/fake/path/.roo/rules" },
334334
{ name: ".vimrc.swp", isFile: () => true, isSymbolicLink: () => false, parentPath: "/fake/path/.roo/rules" },
335-
{ name: ".hidden-file", isFile: () => true, isSymbolicLink: () => false, parentPath: "/fake/path/.roo/rules" },
336335
{ name: "rule2.md", isFile: () => true, isSymbolicLink: () => false, parentPath: "/fake/path/.roo/rules" },
337-
{ name: ".gitignore", isFile: () => true, isSymbolicLink: () => false, parentPath: "/fake/path/.roo/rules" },
336+
{ name: "file.swo", isFile: () => true, isSymbolicLink: () => false, parentPath: "/fake/path/.roo/rules" },
338337
] as any)
339338

340339
statMock.mockImplementation((path) => {
@@ -347,27 +346,24 @@ describe("loadRuleFiles", () => {
347346
const pathStr = filePath.toString()
348347
const normalizedPath = pathStr.replace(/\\/g, "/")
349348

350-
// Only rule files should be read - dot files should be skipped
349+
// Only rule files should be read - swap files should be skipped
351350
if (normalizedPath === "/fake/path/.roo/rules/rule1.txt") {
352351
return Promise.resolve("rule 1 content")
353352
}
354353
if (normalizedPath === "/fake/path/.roo/rules/rule2.md") {
355354
return Promise.resolve("rule 2 content")
356355
}
357356

358-
// Dot files should not be read due to filtering
357+
// Swap files should not be read due to filtering
359358
// If they somehow are read, return recognizable content
360359
if (normalizedPath === "/fake/path/.roo/rules/.01-prettier-tree-sitter.md.swp") {
361360
return Promise.resolve("b0VIM 8.2")
362361
}
363362
if (normalizedPath === "/fake/path/.roo/rules/.vimrc.swp") {
364363
return Promise.resolve("VIM_SWAP_CONTENT")
365364
}
366-
if (normalizedPath === "/fake/path/.roo/rules/.hidden-file") {
367-
return Promise.resolve("HIDDEN_FILE_CONTENT")
368-
}
369-
if (normalizedPath === "/fake/path/.roo/rules/.gitignore") {
370-
return Promise.resolve("GITIGNORE_CONTENT")
365+
if (normalizedPath === "/fake/path/.roo/rules/file.swo") {
366+
return Promise.resolve("SWO_CONTENT")
371367
}
372368

373369
return Promise.reject({ code: "ENOENT" })
@@ -379,22 +375,20 @@ describe("loadRuleFiles", () => {
379375
expect(result).toContain("rule 1 content")
380376
expect(result).toContain("rule 2 content")
381377

382-
// Should NOT contain dot file content - they should be filtered out
378+
// Should NOT contain swap file content - they should be filtered out
383379
expect(result).not.toContain("b0VIM 8.2")
384380
expect(result).not.toContain("VIM_SWAP_CONTENT")
385-
expect(result).not.toContain("HIDDEN_FILE_CONTENT")
386-
expect(result).not.toContain("GITIGNORE_CONTENT")
381+
expect(result).not.toContain("SWO_CONTENT")
387382

388-
// Verify dot files are not read at all
389-
const expectedDotFiles = [
383+
// Verify swap files are not read at all
384+
const expectedSwapFiles = [
390385
"/fake/path/.roo/rules/.01-prettier-tree-sitter.md.swp",
391386
"/fake/path/.roo/rules/.vimrc.swp",
392-
"/fake/path/.roo/rules/.hidden-file",
393-
"/fake/path/.roo/rules/.gitignore",
387+
"/fake/path/.roo/rules/file.swo",
394388
]
395389

396-
for (const dotFile of expectedDotFiles) {
397-
const expectedPath = process.platform === "win32" ? dotFile.replace(/\//g, "\\") : dotFile
390+
for (const swapFile of expectedSwapFiles) {
391+
const expectedPath = process.platform === "win32" ? swapFile.replace(/\//g, "\\") : swapFile
398392
expect(readFileMock).not.toHaveBeenCalledWith(expectedPath, "utf-8")
399393
}
400394
})

src/core/prompts/sections/custom-instructions.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -309,11 +309,6 @@ ${joinedSections}`
309309
function shouldIncludeRuleFile(filename: string): boolean {
310310
const basename = path.basename(filename)
311311

312-
// Exclude files that start with . (hidden files, including Vim .swp files)
313-
if (basename.startsWith(".")) {
314-
return false
315-
}
316-
317312
const cachePatterns = [
318313
"*.DS_Store",
319314
"*.bak",

0 commit comments

Comments
 (0)