diff --git a/.changeset/file-delete-description.md b/.changeset/file-delete-description.md new file mode 100644 index 000000000..9239fd0f0 --- /dev/null +++ b/.changeset/file-delete-description.md @@ -0,0 +1,5 @@ +--- +"@agentproto/runtime": patch +--- + +`file_delete`: the tool description now says a directory is deleted recursively with its contents (it said "empty directory"). Behavior is unchanged. diff --git a/packages/runtime/src/__tests__/fs-tools.test.ts b/packages/runtime/src/__tests__/fs-tools.test.ts index bf29b7293..c638a5d3b 100644 --- a/packages/runtime/src/__tests__/fs-tools.test.ts +++ b/packages/runtime/src/__tests__/fs-tools.test.ts @@ -11,7 +11,7 @@ import { HOST_CALLER } from "../caller-scope.js" import { describe, it, expect, beforeEach, afterEach } from "vitest" -import { mkdtempSync, rmSync, writeFileSync } from "node:fs" +import { existsSync, mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs" import { tmpdir } from "node:os" import { join } from "node:path" import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" @@ -119,3 +119,21 @@ describe("file_read — encoding", () => { await cleanup() }) }) + +describe("file_delete — description and behavior", () => { + it("says a directory is deleted recursively, and does so", async () => { + const { client, cleanup } = await makeSetup() + const { tools } = await client.listTools() + const description = tools.find(t => t.name === "file_delete")?.description ?? "" + expect(description).toMatch(/recursive/i) + expect(description).not.toMatch(/empty directory/i) + + mkdirSync(join(tmp, "dir", "sub"), { recursive: true }) + writeFileSync(join(tmp, "dir", "sub", "a.txt"), "x", "utf8") + const result = await client.callTool({ name: "file_delete", arguments: { path: "dir" } }) + expect(result.isError).toBeFalsy() + expect(existsSync(join(tmp, "dir"))).toBe(false) + + await cleanup() + }) +}) diff --git a/packages/runtime/src/fs-tools.ts b/packages/runtime/src/fs-tools.ts index 107834583..87c406111 100644 --- a/packages/runtime/src/fs-tools.ts +++ b/packages/runtime/src/fs-tools.ts @@ -263,7 +263,7 @@ export function registerFsTools( server.tool( "file_delete", - "Delete a file or empty directory in the workspace.", + "Delete a file or directory in the workspace. A directory is deleted recursively, with all its contents; a missing path is not an error.", { path: z.string().describe("Workspace-relative path.") }, async ({ path }) => { const abs = writeAnchor(path, true)