Commit Graph

3 Commits

Author SHA1 Message Date
e414dc0d18 feat: 解决工具沙箱缓存机制问题,增加forceReinstall参数支持 (#114)
* feat: 为promptx_tool增加forceReinstall选项支持

解决工具沙箱缓存机制问题,允许强制重新安装工具依赖。

## 修改内容

### 1. 工具定义更新 (toolDefinitions.js)
- 增加 context.options.forceReinstall 参数支持
- 增加 context.options.timeout 参数支持
- 完善参数描述,说明context用途
- 移除暂时不需要的role_id和session_id参数

### 2. 执行逻辑优化 (ToolCommand.js)
- 支持从context.options提取执行选项
- 将选项传递给ToolSandbox构造函数
- 增加调试日志输出沙箱选项
- 完善JSDoc注释

## 解决的问题

- Issue #107: PromptX工具沙箱缓存机制不支持工具集更新
- 鲁班等AI角色在调试工具时遇到的缓存问题
- 工具依赖更新后无法自动重新安装的问题

## 使用方式

```javascript
// 强制重新安装依赖
{
  tool_resource: "@tool://tool-name",
  parameters: { /* 工具参数 */ },
  context: {
    options: {
      forceReinstall: true
    }
  }
}
```

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* refactor: 简化context参数,移除暂时不需要的role_id和session_id

按照奥卡姆剃刀原则,移除当前没有实际用途的参数:
- 移除 context.role_id
- 移除 context.session_id
- 保留 context.options 用于执行配置
- 简化API接口,降低复杂度

未来如需要可重新添加这些参数。

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* refactor: 简化promptx_tool参数结构,移除context层级

## 主要改进

### 1. 扁平化参数结构
- 移除复杂的context嵌套,直接使用顶级参数
- forceReinstall 和 timeout 作为可选的顶级参数
- 遵循MCP协议惯例,降低AI理解成本

### 2. 参数说明优化
- forceReinstall: 明确默认值为false
- 详细说明使用场景:工具开发和调试中的缓存问题
- timeout: 明确默认值为30000ms

### 3. 防止盲目调用
- 增加重要提醒:要求AI先了解工具说明再调用
- 避免大模型在不了解工具的情况下盲目执行

## 新的调用方式

## 优势
- 符合MCP预训练共识,降低AI学习成本
- 参数结构简洁直观
- 保持向后兼容性

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-07-05 08:00:02 +08:00
ffb5b4adaf fix: 修复InitCommand项目路径识别问题,优化角色发现机制
主要修改:
• 修复InitCommand.js中AI提供路径优先级配置问题
• 重构Luban角色思维模式文件结构,提升代码组织
• 优化工具执行系统,清理技术债务
• 更新package.registry.json反映最新资源结构

影响:解决了technical-product-manager等角色无法发现的关键问题

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-06-28 22:11:17 +08:00
e54550a835 refactor: 重构PromptXToolCommand为ToolCommand并移至标准目录
📁 文件重构
- 移动: src/lib/commands/PromptXToolCommand.js → src/lib/core/pouch/commands/ToolCommand.js
- 重命名: PromptXToolCommand → ToolCommand
- 统一: 与其他Command文件保持相同目录结构

🔧 代码更新
Class:
- class PromptXToolCommand → class ToolCommand
- 更新module.exports导出名称

Imports:
- 修正BasePouchCommand相对路径引用
- 修正getGlobalResourceManager相对路径引用
- 修正ToolExecutor和logger相对路径引用

References:
- src/lib/core/pouch/commands/index.js: 更新import和export
- src/lib/core/pouch/PouchCLI.js: 更新commands.ToolCommand引用

📂 目录结构统一
src/lib/core/pouch/commands/
├── ActionCommand.js
├── InitCommand.js
├── LearnCommand.js
├── RecallCommand.js
├── RememberCommand.js
├── ToolCommand.js          # 新位置
├── WelcomeCommand.js
└── index.js

 验证通过
- @tool://calculator 减法功能正常: 100 - 58 = 42
- 所有引用路径正确
- 命名规范统一
- 目录结构规范

💡 重构收益
- 遵循项目命名约定
- 统一Command文件组织
- 简化类名提升可读性
- 便于维护和扩展

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-06-28 14:31:57 +08:00