diff --git a/core/tools/definitions/index.ts b/core/tools/definitions/index.ts index 784926526..77a0f30f0 100644 --- a/core/tools/definitions/index.ts +++ b/core/tools/definitions/index.ts @@ -19,4 +19,3 @@ export { singleFindAndReplaceTool } from "./singleFindAndReplace"; export { viewDiffTool } from "./viewDiff"; export { viewRepoMapTool } from "./viewRepoMap"; export { viewSubdirectoryTool } from "./viewSubdirectory"; - diff --git a/core/tools/definitions/readFileHead.ts b/core/tools/definitions/readFileHead.ts index 25530dbb0..e14edc749 100644 --- a/core/tools/definitions/readFileHead.ts +++ b/core/tools/definitions/readFileHead.ts @@ -39,4 +39,4 @@ export const readFileHeadTool: Tool = { ], }, defaultToolPolicy: "allowedWithoutPermission", -}; \ No newline at end of file +}; diff --git a/core/tools/definitions/readFileRange.ts b/core/tools/definitions/readFileRange.ts index 726d64a60..91e94d574 100644 --- a/core/tools/definitions/readFileRange.ts +++ b/core/tools/definitions/readFileRange.ts @@ -4,9 +4,12 @@ import { BUILT_IN_GROUP_NAME, BuiltInToolNames } from "../builtIn"; export const readFileRangeTool: Tool = { type: "function", displayTitle: "Read File Range", - wouldLikeTo: "read lines {{{ startLine }}}-{{{ endLine }}} of {{{ filepath }}}", - isCurrently: "reading lines {{{ startLine }}}-{{{ endLine }}} of {{{ filepath }}}", - hasAlready: "viewed lines {{{ startLine }}}-{{{ endLine }}} of {{{ filepath }}}", + wouldLikeTo: + "read lines {{{ startLine }}}-{{{ endLine }}} of {{{ filepath }}}", + isCurrently: + "reading lines {{{ startLine }}}-{{{ endLine }}} of {{{ filepath }}}", + hasAlready: + "viewed lines {{{ startLine }}}-{{{ endLine }}} of {{{ filepath }}}", readonly: true, isInstant: true, group: BUILT_IN_GROUP_NAME, @@ -45,4 +48,4 @@ export const readFileRangeTool: Tool = { ], }, defaultToolPolicy: "allowedWithoutPermission", -}; \ No newline at end of file +}; diff --git a/core/tools/implementations/readFileHead.integration.vitest.ts b/core/tools/implementations/readFileHead.integration.vitest.ts index 31817c1e9..554a2abbd 100644 --- a/core/tools/implementations/readFileHead.integration.vitest.ts +++ b/core/tools/implementations/readFileHead.integration.vitest.ts @@ -88,8 +88,6 @@ test("readFileHeadImpl validates lines parameter", async () => { ).rejects.toThrow("lines must be 1 or greater"); }); - - test("readFileHead handles file not found errors", async () => { const { resolveRelativePathInDir } = await import("../../util/ideUtils"); @@ -110,4 +108,4 @@ test("readFileHead handles file not found errors", async () => { mockExtras, ), ).rejects.toThrow('File "nonexistent.txt" does not exist'); -}); \ No newline at end of file +}); diff --git a/core/tools/implementations/readFileHead.ts b/core/tools/implementations/readFileHead.ts index 414874247..aed12d2c2 100644 --- a/core/tools/implementations/readFileHead.ts +++ b/core/tools/implementations/readFileHead.ts @@ -50,4 +50,4 @@ export const readFileHeadImpl: ToolImpl = async (args, extras) => { }, }, ]; -}; \ No newline at end of file +}; diff --git a/core/tools/implementations/readFileHead.vitest.ts b/core/tools/implementations/readFileHead.vitest.ts index 086db5ad6..e3ab3b163 100644 --- a/core/tools/implementations/readFileHead.vitest.ts +++ b/core/tools/implementations/readFileHead.vitest.ts @@ -9,15 +9,15 @@ test("readFileHead validates input arguments", () => { // Test missing arguments expect(() => getNumberArg({}, "lines")).toThrow( - "Argument `lines` is required (type number)" + "Argument `lines` is required (type number)", ); // Test invalid arguments expect(() => getNumberArg({ lines: "not-a-number" }, "lines")).toThrow( - "Argument `lines` must be a valid number" + "Argument `lines` must be a valid number", ); expect(() => getNumberArg({ lines: true }, "lines")).toThrow( - "Argument `lines` must be a valid number" + "Argument `lines` must be a valid number", ); }); @@ -30,4 +30,4 @@ test("readFileHead handles line number conversion correctly", () => { // Test that negative numbers are parsed (validation happens in implementation) expect(getNumberArg({ lines: -5 }, "lines")).toBe(-5); -}); \ No newline at end of file +}); diff --git a/core/tools/implementations/readFileRange.integration.vitest.ts b/core/tools/implementations/readFileRange.integration.vitest.ts index a30c7f1d9..945d03e41 100644 --- a/core/tools/implementations/readFileRange.integration.vitest.ts +++ b/core/tools/implementations/readFileRange.integration.vitest.ts @@ -72,15 +72,21 @@ test("readFileRangeImpl handles out-of-bounds ranges gracefully", async () => { expect(result2[0].description).toBe("test.txt (lines 5-100)"); // Verify that IDE methods were called with correct 0-based ranges - expect(mockIdeOutOfBounds.readRangeInFile).toHaveBeenCalledWith("file:///test.txt", { - start: { line: 99, character: 0 }, // 100 - 1 - end: { line: 104, character: Number.MAX_SAFE_INTEGER }, // 105 - 1 - }); + expect(mockIdeOutOfBounds.readRangeInFile).toHaveBeenCalledWith( + "file:///test.txt", + { + start: { line: 99, character: 0 }, // 100 - 1 + end: { line: 104, character: Number.MAX_SAFE_INTEGER }, // 105 - 1 + }, + ); - expect(mockIdePartialRange.readRangeInFile).toHaveBeenCalledWith("file:///test.txt", { - start: { line: 4, character: 0 }, // 5 - 1 - end: { line: 99, character: Number.MAX_SAFE_INTEGER }, // 100 - 1 - }); + expect(mockIdePartialRange.readRangeInFile).toHaveBeenCalledWith( + "file:///test.txt", + { + start: { line: 4, character: 0 }, // 5 - 1 + end: { line: 99, character: Number.MAX_SAFE_INTEGER }, // 100 - 1 + }, + ); }); test("readFileRangeImpl validates line number constraints", async () => { @@ -147,7 +153,9 @@ test("readFileRangeImpl validates line number constraints", async () => { }, mockExtras, ), - ).rejects.toThrow("endLine (5) must be greater than or equal to startLine (10)"); + ).rejects.toThrow( + "endLine (5) must be greater than or equal to startLine (10)", + ); }); test("readFileRangeImpl handles normal ranges correctly", async () => { @@ -194,5 +202,3 @@ test("readFileRangeImpl handles normal ranges correctly", async () => { end: { line: 3, character: Number.MAX_SAFE_INTEGER }, // 4 - 1 }); }); - - diff --git a/core/tools/implementations/readFileRange.ts b/core/tools/implementations/readFileRange.ts index e2b4411c5..c313f4bff 100644 --- a/core/tools/implementations/readFileRange.ts +++ b/core/tools/implementations/readFileRange.ts @@ -12,13 +12,19 @@ export const readFileRangeImpl: ToolImpl = async (args, extras) => { // Validate that line numbers are positive integers if (startLine < 1) { - throw new Error("startLine must be 1 or greater. Negative line numbers are not supported - use the terminal tool with 'tail' command for reading from file end."); + throw new Error( + "startLine must be 1 or greater. Negative line numbers are not supported - use the terminal tool with 'tail' command for reading from file end.", + ); } if (endLine < 1) { - throw new Error("endLine must be 1 or greater. Negative line numbers are not supported - use the terminal tool with 'tail' command for reading from file end."); + throw new Error( + "endLine must be 1 or greater. Negative line numbers are not supported - use the terminal tool with 'tail' command for reading from file end.", + ); } if (endLine < startLine) { - throw new Error(`endLine (${endLine}) must be greater than or equal to startLine (${startLine})`); + throw new Error( + `endLine (${endLine}) must be greater than or equal to startLine (${startLine})`, + ); } const firstUriMatch = await resolveRelativePathInDir(filepath, extras.ide); @@ -59,4 +65,4 @@ export const readFileRangeImpl: ToolImpl = async (args, extras) => { }, }, ]; -}; \ No newline at end of file +}; diff --git a/core/tools/implementations/readFileRange.vitest.ts b/core/tools/implementations/readFileRange.vitest.ts index 2c8609223..b8a172d1c 100644 --- a/core/tools/implementations/readFileRange.vitest.ts +++ b/core/tools/implementations/readFileRange.vitest.ts @@ -6,26 +6,26 @@ test("readFileRange should validate positive line number arguments", () => { expect(() => getNumberArg({ startLine: 1 }, "startLine")).not.toThrow(); expect(() => getNumberArg({ startLine: "1" }, "startLine")).not.toThrow(); expect(() => getNumberArg({ startLine: 100 }, "startLine")).not.toThrow(); - - // Test positive endLine validation + + // Test positive endLine validation expect(() => getNumberArg({ endLine: 5 }, "endLine")).not.toThrow(); expect(() => getNumberArg({ endLine: "10" }, "endLine")).not.toThrow(); expect(() => getNumberArg({ endLine: 1000 }, "endLine")).not.toThrow(); // Test missing arguments expect(() => getNumberArg({}, "startLine")).toThrow( - "Argument `startLine` is required (type number)" + "Argument `startLine` is required (type number)", ); expect(() => getNumberArg({}, "endLine")).toThrow( - "Argument `endLine` is required (type number)" + "Argument `endLine` is required (type number)", ); // Test invalid arguments - expect(() => getNumberArg({ startLine: "not-a-number" }, "startLine")).toThrow( - "Argument `startLine` must be a valid number" - ); + expect(() => + getNumberArg({ startLine: "not-a-number" }, "startLine"), + ).toThrow("Argument `startLine` must be a valid number"); expect(() => getNumberArg({ endLine: true }, "endLine")).toThrow( - "Argument `endLine` must be a valid number" + "Argument `endLine` must be a valid number", ); }); @@ -50,7 +50,7 @@ test("readFileRange handles out-of-bounds ranges gracefully", () => { // - VS Code: Uses array.slice() which handles out-of-bounds gracefully // - IntelliJ: Uses lines.getOrNull() which returns null for out-of-bounds // Both return empty content or available content without throwing errors - + expect(() => { const startLine = getNumberArg({ startLine: 1000 }, "startLine"); const endLine = getNumberArg({ endLine: 2000 }, "endLine"); diff --git a/core/tools/parseArgs.vitest.ts b/core/tools/parseArgs.vitest.ts index 1270d3b9d..71bfc0cc5 100644 --- a/core/tools/parseArgs.vitest.ts +++ b/core/tools/parseArgs.vitest.ts @@ -5,7 +5,7 @@ import { getNumberArg, getOptionalStringArg, getStringArg, - safeParseToolCallArgs + safeParseToolCallArgs, } from "./parseArgs"; describe("safeParseToolCallArgs", () => {