feat: delete_symbol — AST-aware symbol deletion via tree-sitter (6 languages) | AST 符号删除工具#2191
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
e56eb2c
Compare
esengine
left a comment
There was a problem hiding this comment.
Reviewed — equally solid, and I like that it reuses the existing code-query/symbols tree-sitter extraction rather than adding a new parser dependency. Safety mirrors delete_range: exactly-one-match required (0 → no-op, >1 → error returning candidates with kind/line/parent to disambiguate), read_file enforced, ReviewGatedEditTool + auto-git-rollback wired, kind/parent filters for precision. Reusing proven symbol extraction is the right call.
Two notes:
- Will need a rebase — I just merged #2190 (delete_range), which touches the same registration points (tools.ts, edit.ts, filesystem.ts, edit-tool-gate.ts, auto-git-rollback.ts, prompt.ts). Quick rebase onto current main and it's good.
- Non-blocking: confirm the deleted node range covers leading decorators / preceding doc-comments (Python
@decorator, TS decorators, JSDoc) — if the symbol's AST range starts at thefunction/classkeyword, deleting it could orphan a decorator or leave a dangling doc-comment. The review gate catches it visually, but worth a test case (delete a decorated symbol, assert the decorator goes too) ifextractSymbolsincludes them in range.
Approving the approach; rebase for the merge.
e56eb2c to
8056d16
Compare
esengine
left a comment
There was a problem hiding this comment.
Re-reviewed after the rebase — clean against current main now (the delete_range registration points it conflicted with are reconciled). My earlier approval stands: reuses the existing code-query/symbols tree-sitter extraction (no new parser dep), exactly-one-match safety (0 → no-op, >1 → error with candidates), read_file enforced, review-gated, auto-git-rollback wired. CLEAN + CI green. Merging.
Summary
Adds a
delete_symboltool that deletes one function/class/method/interface/type by exact name using tree-sitter AST parsing. Supports TS/TSX/JS/JSX/Python/Go/Rust/Java. Parameters:path,name,kind(optional filter),parent(optional parent class/namespace filter). Multi-match fails and returns candidates with kind/line/parent for the model to disambiguate. Integrated into the edit review/auto/yolo gate withread_fileenforcement via ReadTracker. v1 is delete-only (no replace-symbol).概述
新增
delete_symbol工具,使用 tree-sitter AST 解析按精确名称删除函数/类/方法/接口/类型。支持 TS/TSX/JS/JSX/Python/Go/Rust/Java。参数:path、name、kind(可选过滤)、parent(可选父类/命名空间过滤)。多匹配时失败并返回候选项供模型消歧义。集成到 edit review/auto/yolo 门禁,通过 ReadTracker 强制执行 read_file。v1 仅做删除(无 replace-symbol)。Key Files
src/tools/filesystem.ts—delete_symboltool with tree-sitter integrationsrc/tools/fs/edit.ts—applyDeleteLineRange(),computeDeleteLineRangePatchFromText()src/cli/ui/edit-tool-gate.ts—buildDeleteSymbolBlock(), review gatesrc/cli/ui/App.tsx— ReadTracker in edit-gate interceptorsrc/code/lifecycle-policy.ts— high-risk classificationtests/delete-tools.test.ts— AST deletion testDepends On / 依赖
This PR is #4 in a 5-PR series:
plan-resumedrole from ink to frame #5: SSH Remote Workspace RFCTest Plan
Verification