delete_file
Remove files or directories from the Windows system to manage storage and organize data efficiently.
Instructions
删除文件或目录
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | 文件或目录路径 |
Implementation Reference
- src/tools/filesystem.js:179-191 (handler)The handler function that executes the delete_file tool: determines if the path is a file or directory and deletes it using fs.unlink or fs.rm with error handling.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)Schema definition for the delete_file tool, specifying the input as an object with required 'path' string.{ name: 'delete_file', description: '删除文件或目录', inputSchema: { type: 'object', properties: { path: { type: 'string', description: '文件或目录路径' }, }, required: ['path'], }, },
- src/tools/filesystem.js:125-126 (registration)Registration of delete_file handler in the executeTool method's switch statement.case 'delete_file': return await this.deleteFile(args.path);
- src/tools/filesystem.js:111-111 (registration)Includes 'delete_file' in the array of supported tool names checked by canHandle.'delete_file', 'copy_file', 'move_file', 'search_files'];