Skip to content

pref(tool):删除无用工具#678

Merged
pionxe merged 1 commit into
1024XEngineer:mainfrom
phantom5099:main
May 21, 2026
Merged

pref(tool):删除无用工具#678
pionxe merged 1 commit into
1024XEngineer:mainfrom
phantom5099:main

Conversation

@phantom5099
Copy link
Copy Markdown
Collaborator

Closes: #677

摘要

删除 filesystem_move_filefilesystem_copy_filefilesystem_create_dirfilesystem_remove_dir 四个已不再被模型调用的死代码工具,同步清理所有关联代码路径,净删除约 1700 行。

动机

四个工具在当前的 ReAct 链路中已无实际调用:文件移动/复制通过 filesystem_write_file 直接写入目标路径完成,目录操作由 bash 兜底。但它们仍然存在于工具注册表、提示词、权限映射、Runtime 写入检测链路和前端文件变更面板中,每次请求都被携带且维护着不会命中的分支逻辑。

变更清单

删除 (8 文件)

  • internal/tools/filesystem/move_file.go + _test.go
  • internal/tools/filesystem/copy_file.go + _test.go
  • internal/tools/filesystem/remove_dir.go + _test.go
  • internal/tools/filesystem/create_dir.go + _test.go

工具注册与常量

  • internal/tools/names.go: 移除 4 个 ToolNameFilesystem* 常量
  • internal/tools/filesystem/helpers.go: 移除 4 个本地工具名常量
  • internal/tools/permission_mapper.go: 移除 4 个权限映射 case
  • internal/app/bootstrap.go: 移除 4 个 Register() 调用
  • internal/runner/runner.go: 移除 4 个 Register() 调用

Runtime 链路

  • internal/runtime/toolexec.go:
    • 移除 remove_dir 递归预捕获逻辑(filepath.WalkDir
    • 移除 RemoveDir/MoveFileCapturePostDelete 分支
    • isFileWriteTool: 7→3 个 case
    • toolCallTouchedPaths: 去掉 switch 分支,统一从 path 字段解析
  • internal/runtime/run.go: 更新过时注释

Context 与 Pin 策略

  • internal/context/pin_checker.go: 从 defaultPinToolNames 移除 copy/move

提示词

  • internal/promptasset/templates/core/tool_usage.md: 移除 4 行工具使用指令

前端

  • web/src/utils/eventBridge.ts: FILE_WRITE_TOOLS 5→3 个,移除 _trackFileChangeFromTool 中 move/copy 双路径分支

文档

  • docs/architecture/architecture-v1.md: 移除 4 个工具行

测试

同步修剪 tool_metadata_test.gohelpers_test.goformat_test.gopin_checker_test.gomicrocompact_test.gotool_diff_helpers_test.goper_edit_snapshot_test.goeventBridge.test.ts 中的相关用例。

测试计划

  • go build ./... — 通过
  • go test ./internal/tools/... — 通过
  • go test ./internal/runtime/... — 通过
  • go test ./internal/context/... — 通过
  • go test ./internal/checkpoint/... — 通过
  • go test ./internal/app/... — 通过
  • go test ./internal/runner/... — 通过
  • 全量 grep 确认 0 残留引用(ToolNameFilesystemMoveFilefilesystem_move_file 等均无匹配)

影响面

  • 无功能影响:bash 工具覆盖目录创建/删除,filesystem_write_file 覆盖文件移动/复制能力
  • 无协议兼容性影响:工具名常量不在协议层使用
  • 回放兼容:历史会话中已记录的工具调用仅包含 string 形式的 metadata,不受常量删除影响

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Credits must be used to enable repository wide code reviews.

Copy link
Copy Markdown

@fennoai fennoai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found one behavioral regression in the checkpoint/restore path after removing the dedicated filesystem tools.

@@ -290,17 +273,6 @@ func (s *Service) executeOneToolCallWithoutPersistence(

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

High: removing the CapturePostDelete handling here regresses per-edit restore coverage for the only remaining path that can rename files or delete directories: bash. BashLikelyWritesFiles/SourceFilesInWorkdir only pre-capture file-like tokens with recognized source extensions, so operations like mv assets/logo.png assets/logo.old, mv dir1 dir2, or rm -rf build/ no longer record the deleted side/tree in the snapshot store. After such a command, restoring a checkpoint cannot recreate the source path or directory contents, which is a behavior change from the removed dedicated tools.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 20, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@pionxe pionxe merged commit 542c15c into 1024XEngineer:main May 21, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

移除已废弃的文件系统工具:MoveFile / CopyFile / CreateDir / RemoveDir

2 participants