Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/file-delete-description.md
Original file line number Diff line number Diff line change
@@ -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.
20 changes: 19 additions & 1 deletion packages/runtime/src/__tests__/fs-tools.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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()
})
})
2 changes: 1 addition & 1 deletion packages/runtime/src/fs-tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading