delete_file
Remove files or directories from Windows systems to manage disk space and maintain organized file structures.
Instructions
删除文件或目录
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | 文件或目录路径 |
Input Schema (JSON Schema)
{
"properties": {
"path": {
"description": "文件或目录路径",
"type": "string"
}
},
"required": [
"path"
],
"type": "object"
}
Implementation Reference
- src/tools/filesystem.js:179-191 (handler)The core handler function that deletes a file or directory. It checks if the path is a directory using fs.stat and uses fs.rm (recursive) for directories or fs.unlink for files.async deleteFile(filePath) { try { const stats = await fs.stat(filePath); if (stats.isDirectory()) { await fs.rm(filePath, { recursive: true, force: true }); } else { await fs.unlink(filePath); } return { success: true, path: filePath, message: '删除成功' }; } catch (error) { return { success: false, error: error.message }; } }
- src/tools/filesystem.js:59-69 (schema)Tool schema definition including name, description, and input schema requiring a 'path' parameter.{ name: 'delete_file', description: '删除文件或目录', inputSchema: { type: 'object', properties: { path: { type: 'string', description: '文件或目录路径' }, }, required: ['path'], }, },
- src/tools/filesystem.js:125-126 (registration)Registration of the delete_file tool within the executeTool switch statement, dispatching to the deleteFile handler.case 'delete_file': return await this.deleteFile(args.path);
- src/tools/filesystem.js:110-112 (registration)Includes 'delete_file' in the list of handled tools in the canHandle method.const tools = ['read_file', 'write_file', 'list_directory', 'create_directory', 'delete_file', 'copy_file', 'move_file', 'search_files']; return tools.includes(toolName);