diff --git a/src/lib/tools/TextEditorWriteTool.ts b/src/lib/tools/TextEditorWriteTool.ts index f82635b1..e07c0fed 100644 --- a/src/lib/tools/TextEditorWriteTool.ts +++ b/src/lib/tools/TextEditorWriteTool.ts @@ -1,22 +1,9 @@ -import { join } from "@std/path"; +import { join, dirname } from "@std/path"; import { z } from "zod"; import type { Tool, CallToolResult } from "./Tool"; import type { JSRuntimeFS } from "../JSRuntime"; -// Simple dirname implementation that works in browser environments -function dirname(path: string): string { - if (path === '' || path === '.') return '.'; - - // Handle Windows and Unix paths - const lastSlash = Math.max(path.lastIndexOf('/'), path.lastIndexOf('\\')); - - if (lastSlash === -1) return '.'; - if (lastSlash === 0) return '/'; - - return path.slice(0, lastSlash); -} - interface TextEditorWriteParams { path: string; file_text: string;