From 71047ab31bec6b98632833c8dc1e15e293235156 Mon Sep 17 00:00:00 2001 From: Roo Code Date: Fri, 18 Jul 2025 13:35:51 +0000 Subject: [PATCH] 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 --- .../__tests__/custom-instructions.spec.ts | 34 ++++++++----------- .../prompts/sections/custom-instructions.ts | 5 --- 2 files changed, 14 insertions(+), 25 deletions(-) diff --git a/src/core/prompts/sections/__tests__/custom-instructions.spec.ts b/src/core/prompts/sections/__tests__/custom-instructions.spec.ts index c12e3937b9..92c84a83f6 100644 --- a/src/core/prompts/sections/__tests__/custom-instructions.spec.ts +++ b/src/core/prompts/sections/__tests__/custom-instructions.spec.ts @@ -321,20 +321,19 @@ describe("loadRuleFiles", () => { } }) - it("should filter out Vim swap files and other dot files from .roo/rules/ directory", async () => { + it("should filter out Vim swap files from .roo/rules/ directory", async () => { // Simulate .roo/rules directory exists statMock.mockResolvedValueOnce({ isDirectory: vi.fn().mockReturnValue(true), } as any) - // Simulate listing files including Vim swap files and other dot files + // Simulate listing files including Vim swap files readdirMock.mockResolvedValueOnce([ { name: "rule1.txt", isFile: () => true, isSymbolicLink: () => false, parentPath: "/fake/path/.roo/rules" }, { name: ".01-prettier-tree-sitter.md.swp", isFile: () => true, isSymbolicLink: () => false, parentPath: "/fake/path/.roo/rules" }, { name: ".vimrc.swp", isFile: () => true, isSymbolicLink: () => false, parentPath: "/fake/path/.roo/rules" }, - { name: ".hidden-file", isFile: () => true, isSymbolicLink: () => false, parentPath: "/fake/path/.roo/rules" }, { name: "rule2.md", isFile: () => true, isSymbolicLink: () => false, parentPath: "/fake/path/.roo/rules" }, - { name: ".gitignore", isFile: () => true, isSymbolicLink: () => false, parentPath: "/fake/path/.roo/rules" }, + { name: "file.swo", isFile: () => true, isSymbolicLink: () => false, parentPath: "/fake/path/.roo/rules" }, ] as any) statMock.mockImplementation((path) => { @@ -347,7 +346,7 @@ describe("loadRuleFiles", () => { const pathStr = filePath.toString() const normalizedPath = pathStr.replace(/\\/g, "/") - // Only rule files should be read - dot files should be skipped + // Only rule files should be read - swap files should be skipped if (normalizedPath === "/fake/path/.roo/rules/rule1.txt") { return Promise.resolve("rule 1 content") } @@ -355,7 +354,7 @@ describe("loadRuleFiles", () => { return Promise.resolve("rule 2 content") } - // Dot files should not be read due to filtering + // Swap files should not be read due to filtering // If they somehow are read, return recognizable content if (normalizedPath === "/fake/path/.roo/rules/.01-prettier-tree-sitter.md.swp") { return Promise.resolve("b0VIM 8.2") @@ -363,11 +362,8 @@ describe("loadRuleFiles", () => { if (normalizedPath === "/fake/path/.roo/rules/.vimrc.swp") { return Promise.resolve("VIM_SWAP_CONTENT") } - if (normalizedPath === "/fake/path/.roo/rules/.hidden-file") { - return Promise.resolve("HIDDEN_FILE_CONTENT") - } - if (normalizedPath === "/fake/path/.roo/rules/.gitignore") { - return Promise.resolve("GITIGNORE_CONTENT") + if (normalizedPath === "/fake/path/.roo/rules/file.swo") { + return Promise.resolve("SWO_CONTENT") } return Promise.reject({ code: "ENOENT" }) @@ -379,22 +375,20 @@ describe("loadRuleFiles", () => { expect(result).toContain("rule 1 content") expect(result).toContain("rule 2 content") - // Should NOT contain dot file content - they should be filtered out + // Should NOT contain swap file content - they should be filtered out expect(result).not.toContain("b0VIM 8.2") expect(result).not.toContain("VIM_SWAP_CONTENT") - expect(result).not.toContain("HIDDEN_FILE_CONTENT") - expect(result).not.toContain("GITIGNORE_CONTENT") + expect(result).not.toContain("SWO_CONTENT") - // Verify dot files are not read at all - const expectedDotFiles = [ + // Verify swap files are not read at all + const expectedSwapFiles = [ "/fake/path/.roo/rules/.01-prettier-tree-sitter.md.swp", "/fake/path/.roo/rules/.vimrc.swp", - "/fake/path/.roo/rules/.hidden-file", - "/fake/path/.roo/rules/.gitignore", + "/fake/path/.roo/rules/file.swo", ] - for (const dotFile of expectedDotFiles) { - const expectedPath = process.platform === "win32" ? dotFile.replace(/\//g, "\\") : dotFile + for (const swapFile of expectedSwapFiles) { + const expectedPath = process.platform === "win32" ? swapFile.replace(/\//g, "\\") : swapFile expect(readFileMock).not.toHaveBeenCalledWith(expectedPath, "utf-8") } }) diff --git a/src/core/prompts/sections/custom-instructions.ts b/src/core/prompts/sections/custom-instructions.ts index e621c4c5f4..3c8558a57f 100644 --- a/src/core/prompts/sections/custom-instructions.ts +++ b/src/core/prompts/sections/custom-instructions.ts @@ -309,11 +309,6 @@ ${joinedSections}` function shouldIncludeRuleFile(filename: string): boolean { const basename = path.basename(filename) - // Exclude files that start with . (hidden files, including Vim .swp files) - if (basename.startsWith(".")) { - return false - } - const cachePatterns = [ "*.DS_Store", "*.bak",