Skip to content

Conversation

binggg
Copy link
Member

@binggg binggg commented Sep 3, 2025

功能描述

重构 storage.ts 工具,实现读写分离的设计模式,并增加删除文件功能。

主要变更

✨ 新功能

  • queryStorage: 只读操作工具,支持列出文件、获取文件信息、获取临时链接
  • manageStorage: 写操作工具,支持上传、下载、删除文件/目录
  • 删除功能: 新增 deleteFile 和 deleteDirectory 操作,需要 force=true 确认

🔄 重构改进

  • 参考 cloudrun.ts 的读写分离模式
  • 保持向后兼容性
  • 统一的错误处理和返回格式
  • 完整的参数验证和类型安全

🧪 测试覆盖

  • 新增完整的集成测试
  • 验证工具注册、schema 验证、注解正确性
  • 所有测试通过 ✅

技术细节

  • 使用 Zod 进行输入参数验证
  • 遵循 MCP 工具注册规范
  • 支持文件上传/下载进度回调
  • 删除操作安全确认机制

使用示例

// 查询文件列表
queryStorage({ action: 'list', cloudPath: 'files/' })

// 删除文件(需要确认)
manageStorage({ 
  action: 'delete', 
  cloudPath: 'files/test.txt', 
  force: true 
})

测试结果

✅ Storage tools are registered correctly
✅ queryStorage tool schema validation passed
✅ manageStorage tool schema validation passed  
✅ Storage tools annotations are correct

Closes: #N/A

- Split storage.ts into queryStorage (read-only) and manageStorage (write operations)
- Add deleteFile and deleteDirectory functionality with force confirmation
- Implement complete file management operations (upload, download, delete)
- Follow cloudrun.ts design pattern for consistency
- Add comprehensive test coverage for new tools
- Maintain backward compatibility while enhancing functionality
@binggg binggg merged commit 5148349 into main Sep 3, 2025
2 checks passed
binggg added a commit that referenced this pull request Sep 4, 2025
…efactor

feat(storage): 🔄 refactor storage tools to read-write separation pattern
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant