From deac90f18e5eed55a21be064500958e06d8bd9d5 Mon Sep 17 00:00:00 2001 From: zerone0x Date: Sat, 14 Feb 2026 18:46:04 +0800 Subject: [PATCH] fix: preserve leading dot in ls tool path resolution The `resolveLsToolDirPath` function incorrectly stripped leading dots from paths like `.continue/rules`, converting them to `continue/rules` which doesn't exist. This broke the ls tool for any hidden directory. Remove the faulty condition that matched paths starting with "." but not "./" and stripped their first character. The path resolver handles these paths correctly without preprocessing. Fixes #10466 Co-Authored-By: Claude --- core/tools/implementations/lsTool.ts | 4 ---- core/tools/implementations/lsTool.vitest.ts | 13 +++++++++++++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/core/tools/implementations/lsTool.ts b/core/tools/implementations/lsTool.ts index 8fc9a044e22..d4ef4e622b7 100644 --- a/core/tools/implementations/lsTool.ts +++ b/core/tools/implementations/lsTool.ts @@ -9,10 +9,6 @@ export function resolveLsToolDirPath(dirPath: string | undefined) { if (!dirPath || dirPath === ".") { return "."; } - // Don't strip leading slash from absolute paths - let the resolver handle it - if (dirPath.startsWith(".") && !dirPath.startsWith("./")) { - return dirPath.slice(1); - } return dirPath.replace(/\\/g, "/"); } diff --git a/core/tools/implementations/lsTool.vitest.ts b/core/tools/implementations/lsTool.vitest.ts index 7ec20682715..1b2fef32abd 100644 --- a/core/tools/implementations/lsTool.vitest.ts +++ b/core/tools/implementations/lsTool.vitest.ts @@ -36,6 +36,19 @@ test("resolveLsToolDirPath preserves forward slashes", () => { expect(resolveLsToolDirPath("path/to/dir")).toBe("path/to/dir"); }); +test("resolveLsToolDirPath preserves hidden directory paths", () => { + expect(resolveLsToolDirPath(".continue/rules")).toBe(".continue/rules"); +}); + +test("resolveLsToolDirPath preserves hidden directory name only", () => { + expect(resolveLsToolDirPath(".git")).toBe(".git"); +}); + +test("resolveLsToolDirPath preserves parent directory references", () => { + expect(resolveLsToolDirPath("..")).toBe(".."); + expect(resolveLsToolDirPath("../foo")).toBe("../foo"); +}); + test("lsToolImpl truncates output when entries exceed MAX_LS_TOOL_LINES", async () => { // Generate more than MAX_LS_TOOL_LINES entries (which is 200) const mockEntries = Array.from({ length: 250 }, (_, i) => `file${i}.txt`);