From f18a16aa0f7056313ee9c7c941492e314430cf9d Mon Sep 17 00:00:00 2001 From: Ashwin Bhat Date: Tue, 27 May 2025 17:06:57 -0700 Subject: [PATCH] prettier --- src/create-prompt/index.ts | 12 ++++++++---- test/create-prompt.test.ts | 16 +++++++++++----- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/src/create-prompt/index.ts b/src/create-prompt/index.ts index d83a291..9a91110 100644 --- a/src/create-prompt/index.ts +++ b/src/create-prompt/index.ts @@ -61,13 +61,17 @@ export function buildDisallowedToolsString( allowedTools?: string, ): string { let disallowedTools = [...DISALLOWED_TOOLS]; - + // If user has explicitly allowed some hardcoded disallowed tools, remove them from disallowed list if (allowedTools) { - const allowedToolsArray = allowedTools.split(",").map(tool => tool.trim()); - disallowedTools = disallowedTools.filter(tool => !allowedToolsArray.includes(tool)); + const allowedToolsArray = allowedTools + .split(",") + .map((tool) => tool.trim()); + disallowedTools = disallowedTools.filter( + (tool) => !allowedToolsArray.includes(tool), + ); } - + let allDisallowedTools = disallowedTools.join(","); if (customDisallowedTools) { if (allDisallowedTools) { diff --git a/test/create-prompt.test.ts b/test/create-prompt.test.ts index c0cc7a8..3eb493d 100644 --- a/test/create-prompt.test.ts +++ b/test/create-prompt.test.ts @@ -726,11 +726,14 @@ describe("buildDisallowedToolsString", () => { test("should remove hardcoded disallowed tools if they are in allowed tools", () => { const customDisallowedTools = "BadTool1,BadTool2"; const allowedTools = "WebSearch,SomeOtherTool"; - const result = buildDisallowedToolsString(customDisallowedTools, allowedTools); + const result = buildDisallowedToolsString( + customDisallowedTools, + allowedTools, + ); // WebSearch should be removed from disallowed since it's in allowed expect(result).not.toContain("WebSearch"); - + // WebFetch should still be disallowed since it's not in allowed expect(result).toContain("WebFetch"); @@ -746,7 +749,7 @@ describe("buildDisallowedToolsString", () => { // Both hardcoded disallowed tools should be removed expect(result).not.toContain("WebSearch"); expect(result).not.toContain("WebFetch"); - + // Result should be empty since no custom disallowed tools provided expect(result).toBe(""); }); @@ -754,12 +757,15 @@ describe("buildDisallowedToolsString", () => { test("should handle custom disallowed tools when all hardcoded tools are overridden", () => { const customDisallowedTools = "BadTool1,BadTool2"; const allowedTools = "WebSearch,WebFetch"; - const result = buildDisallowedToolsString(customDisallowedTools, allowedTools); + const result = buildDisallowedToolsString( + customDisallowedTools, + allowedTools, + ); // Hardcoded tools should be removed expect(result).not.toContain("WebSearch"); expect(result).not.toContain("WebFetch"); - + // Only custom disallowed tools should remain expect(result).toBe("BadTool1,BadTool2"); });