-
-
Notifications
You must be signed in to change notification settings - Fork 80.7k
edit 工具稳定性改进:4 重防护机制 #62863
Copy link
Copy link
Closed as not planned
Labels
P2Normal backlog priority with limited blast radius.Normal backlog priority with limited blast radius.clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.ClawSweeper found a clear likely implementation shape for this issue.clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.ClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.ClawSweeper marked this issue as needing a product or behavior decision.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.ClawSweeper does not recommend queueing a new automated fix PR for this issue.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.ClawSweeper found a high-confidence source-level issue reproduction.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.Very strong issue quality with high-confidence source-level or clear reproduction.staleMarked as stale due to inactivityMarked as stale due to inactivity
Description
Metadata
Metadata
Assignees
Labels
P2Normal backlog priority with limited blast radius.Normal backlog priority with limited blast radius.clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.ClawSweeper found a clear likely implementation shape for this issue.clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.ClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.ClawSweeper marked this issue as needing a product or behavior decision.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.ClawSweeper does not recommend queueing a new automated fix PR for this issue.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.ClawSweeper found a high-confidence source-level issue reproduction.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.Very strong issue quality with high-confidence source-level or clear reproduction.staleMarked as stale due to inactivityMarked as stale due to inactivity
Type
Fields
Priority
None yet
问题背景
edit 工具要求 oldText 参数与文件内容逐字符精确匹配(包括空格、换行),稍有差异就失败。实际使用中经常因 whitespace 不一致导致编辑失败,触发错误报告。
建议方案
1. 空白归一化兜底(核心改进)
在匹配 oldText 之前,对「文件内容」和「oldText」都做空白归一化:
用归一化后的内容进行匹配,即使有格式差异也能成功。
2. 前置校验步骤
执行 edit 前自动校验:
3. read 定位增强
除了 offset/limit,增加更友好的定位方式:
read file.md line=10 limit=5— 按行号定位read file.md keyword="目标内容" limit=3— 按关键词定位避免手动计算 offset 的误差。
4. 多次小改原则
文档中明确建议:
预期收益
实现优先级
技术提示
空白归一化可以参考 git diff 的 whitespace 处理逻辑,或者借鉴 Prettier 的规范化策略。
来源:用户实际使用中的痛点 + 系统性解决方案