-
Notifications
You must be signed in to change notification settings - Fork 603
New modules:commandTimeoutPredictor、shellAllowlist、observable、promiseUtils、kvStore #154
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
@CrazyBoyM 你能稍微看一下吗?我新增了一些实用功能 |
7710476 to
b1ddd2f
Compare
|
收到,能简单描述下具体增加了解决哪些痛点 & 体验问题的实用功能么?以及commandTimeoutPredictor、observable、kvStore等实现的具体功能作用和效果? |
|
以下是用Agent CLI对简单的审阅: ⏺ PR 解析
1. FileEditTool 增强 - 解决编辑失败问题
痛点: AI 经常因为空格/缩进/精确匹配失败导致文件编辑失败
新增功能:
- 行号提示: 指定 old_str_start_line_number 缩小搜索范围
- 模糊匹配: 容忍 Tab/空格差异
- replace_all: 一次替换所有匹配项
效果: 减少 "old_string not found" 错误
---
2. GrepTool 增强 - 更灵活的搜索
痛点: 搜索结果太多或太少,缺乏上下文
新增功能:
- -A/-B/-C: 显示匹配行前后上下文
- head_limit/offset: 分页,避免输出爆炸
- multiline: 跨行正则匹配
效果: 搜索体验接近真实 ripgrep
---
3. TaskTool 增强 - 并行子代理
痛点: 多任务只能串行执行,效率低
新增功能:
- action: "run"/"output": 启动代理 / 获取结果分离
- name: 命名代理,支持同时运行多个
- 结果持久化,可后续查询
效果: 真正的并行任务执行
---
4. commandTimeoutPredictor - 命令超时预测
功能: 根据历史执行记录预测命令超时时间
git status → 历史平均 2s → 预测超时 10s
npm install → 历史平均 45s → 预测超时 120s
实际价值: 低。当前固定超时已够用,这是过度优化。
---
5. shellAllowlist - Shell 命令白名单
功能: 定义安全命令自动通过,无需用户确认
// 白名单规则示例
{ pattern: /^git (status|log|diff)/, autoApprove: true }
{ pattern: /^npm (list|outdated)/, autoApprove: true }
实际价值: 中。但与现有 YOLO 模式和权限系统设计冲突。
---
6. observable - 响应式状态
功能: 类似 Vue/MobX 的响应式系统
const state = observable({ count: 0 })
const doubled = computed(() => state.count * 2)
state.count = 5 // doubled 自动变为 10
实际价值: 低。项目已用 React + Context,引入新状态系统增加复杂度。
---
7. kvStore - 键值存储
功能: 文件持久化的 KV 数据库
await kvStore.set('user.settings', { theme: 'dark' })
const settings = await kvStore.get('user.settings')
实际价值: 低。当前用 JSON 文件直接读写已够用。
---
8. promiseUtils - Promise 工具
功能:
- retry(fn, { maxRetries: 3, backoff: 'exponential' }) - 重试
- timeout(promise, 5000) - 超时包装
- DeferredPromise - 外部 resolve/reject
实际价值: 中。实用但代码量小,可按需引入。
---
9. applyPatch - V4A Diff 应用
功能: 解析并应用类似 git diff 的补丁格式
实际价值: 高。可作为 FileEditTool 的备选方案,处理大文件更高效。
---
10. checkpointManager - 检查点管理
功能: 文件修改历史追踪 + 一键回滚
checkpoint.save('before-refactor')
// ... AI 改了一堆文件 ...
checkpoint.revert('before-refactor') // 全部还原
实际价值: 高。用户常见需求:"撤销 AI 刚才所有修改"
---
总结
| 模块 | 价值 | 建议 |
|-------------------------|-----|---------|
| FileEditTool 增强 | ⭐⭐⭐ | 可选择性合并 |
| GrepTool 增强 | ⭐⭐⭐ | 部分已实现 |
| TaskTool 并行 | ⭐⭐⭐ | 值得考虑 |
| applyPatch | ⭐⭐⭐ | 单独提取 |
| checkpointManager | ⭐⭐⭐ | 单独提取 |
| promiseUtils | ⭐⭐ | 按需引入 |
| shellAllowlist | ⭐⭐ | 与现有设计冲突 |
| commandTimeoutPredictor | ⭐ | 过度工程 |
| observable | ⭐ | 不必要 |
| kvStore | ⭐ | 不必要 | |
|
shellAllowlist等皆是對使用體驗有所改善的功能 |
感觉allow list可以实现下(当前已经内置了部分命令规则走llm检测,但感觉不太顺滑,可以看一下BashTool实现),命令行那个是现在让大模型自己工具调用的schema里有timeout参数 & 也有后台运行、查看后台运行任务结果,其它两个感觉必要性不强, |
New modules migrated:
Total: 2,400+ lines of code added