feat(tools): 新增 EditFileTool / GlobTool / GrepTool / BashTool#5
Merged
Conversation
- 新增 edit_file 工具:通过 old_string/new_string 精确替换文件片段, 非全量覆写;匹配为 0 次或多次时返回友好错误信息引导模型修正 - 注册 editFileTool 到 allTools 并更新 tools/index.ts 导出 - mock-model v0.4.1:新增"测试编辑"意图检测 - 更新 SYSTEM prompt 和启动提示,加入 edit_file 工具说明
- 新增 glob 工具:基于 fast-glob,支持 * / ** 通配符, 自动忽略 node_modules 和 .git,只读可并发 - 注册 GlobTool 到 allTools 并更新 tools/index.ts 导出 - mock-model:新增"测试glob"意图检测 - 更新 SYSTEM prompt 和启动提示,加入 glob 工具说明
- 新增 grep 工具:递归搜索文件内容,支持正则表达式, 跳过 node_modules/.git/dist 及二进制文件, 最多返回 50 条匹配,只读可并发 - 注册 GrepTool 到 allTools 并更新 tools/index.ts 导出 - mock-model:新增"测试搜索"意图检测 - 更新启动提示,加入"测试搜索"示例
- 新增 bash 工具:通过 execSync 执行 shell 命令,超时 10s, 结果截断至 3000 字符;WebContainer 环境下自动降级并返回友好提示 - 串行执行(isConcurrencySafe: false),防止并发副作用 - 注册 BashTool 到 allTools 并更新 tools/index.ts 导出 - mock-model:新增"测试bash"意图检测 - 更新 SYSTEM prompt 和启动提示,加入 bash 工具说明
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概述
新增 5 个实用工具(
edit_file、glob、grep、bash、list_directory升级),完善工具集,使 Super Agent 具备完整的文件读写、搜索和命令执行能力。变更内容
新增工具
EditFileTool:精确局部替换文件内容(old_string→new_string),匹配 0 次或多次时返回友好错误引导模型修正;串行执行GlobTool:基于fast-glob,支持*/**通配符搜索文件,自动忽略node_modules、.git;只读可并发GrepTool:递归正则搜索文件内容,跳过二进制文件和忽略目录,最多返回 50 条匹配,结果截断至 3000 字符;只读可并发BashTool:执行 shell 命令,超时 10s,WebContainer 环境自动降级提示;串行执行其他变更
sample-data.txt:工具系统设计说明文档,同时作为ReadFileTool截断功能的测试数据preflight脚本:串联lint与format:check,用于 CI 和 PR 前检查fast-glob依赖mock-model v0.4.1:新增测试编辑、测试glob、测试搜索、测试bash意图检测SYSTEM prompt和启动提示,列出全部可用工具检查
pnpm preflight(lint + format:check)✅