feat: delete_range — reliable large text deletion with anchor-based range matching | 大块文本删除工具#2190
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f520f05495
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6426b6823f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6212f5e0ea
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
Part of the #2188–#2192 stack that currently shows the same cumulative +1740/-39 diff on all five PRs (all based on |
6212f5e to
df92d0e
Compare
esengine
left a comment
There was a problem hiding this comment.
Reviewed the now-split, independent PR — this is a well-built, safety-first tool. computeDeleteRangePatchFromText requires exactly one occurrence of each anchor (0 → 'not found', >1 → 'appears N times', both no-op), rejects reversed/empty ranges, and inclusive defaults sensibly. And it's wired into every existing edit-safety layer: safePath(..., "write") for traversal protection, readTracker.hasRead enforcement (anchors must match on-disk bytes), prepareAutoGitRollback for the pre-edit checkpoint, and ReviewGatedEditTool so it routes through the review/auto gate like edit_file. Returns a unified diff, tests in delete-tools.test.ts, CI green. The exactly-one-anchor rule + review gate make accidental/ambiguous deletion essentially impossible. Merging.
Summary
Adds a
delete_rangetool that deletes a contiguous text range from a file using exact start/end text anchors. Parameters:path,start_anchor,end_anchor,inclusive. Requiresread_filefirst (enforced via ReadTracker). No-op on missing/duplicate anchors or reversed ranges. Returns unified diff on success. Integrated into the edit review/auto/yolo gate with CRLF line ending normalization and path traversal protection.概述
新增
delete_range工具,使用精确的开始/结束文本锚点删除文件中的连续文本范围。参数:path、start_anchor、end_anchor、inclusive。要求先 read_file(通过 ReadTracker 强制执行)。缺失/重复锚点或反转范围时 no-op。成功时返回 unified diff。集成到 edit review/auto/yolo 门禁,支持 CRLF 换行符自适应和路径穿越防护。Key Files
src/tools/filesystem.ts—delete_rangetool registrationsrc/tools/fs/edit.ts—applyDeleteRange(),computeDeleteRangePatchFromText()src/tools.ts— gate rejection patternssrc/cli/ui/edit-tool-gate.ts— review/auto gate integrationsrc/code/prompt.ts— recommend delete_range for large deletionssrc/code/lifecycle-policy.ts— high-risk classificationtests/delete-tools.test.ts(new) — unit testsDepends On / 依赖
This PR is #3 in a 5-PR series:
plan-resumedrole from ink to frame #5: SSH Remote Workspace RFCTest Plan
Verification