Skip to content

Add workspace move_file tool for file moves / 新增工作区 move_file 工具处理文件移动#4316

Open
SivanCola wants to merge 5 commits into
main-v2from
fix/move-file-approval
Open

Add workspace move_file tool for file moves / 新增工作区 move_file 工具处理文件移动#4316
SivanCola wants to merge 5 commits into
main-v2from
fix/move-file-approval

Conversation

@SivanCola

Copy link
Copy Markdown
Collaborator

Summary

Fixes #4310.

This adds a workspace-confined move_file built-in for moving or renaming files without going through shell-specific commands such as mv or PowerShell Move-Item.

Why

File move/rename tasks could be routed through bash, where persisted approvals are intentionally scoped by command prefix. Moving several different files can therefore keep prompting even after the user chooses always allow. A dedicated file-mutation tool lets those operations share the existing Edit permission family instead.

What changed

  • Add move_file(source_path, destination_path) with workspace confinement for both source and destination.
  • Include move_file in the file-mutation permission family, CLI/ACP/evidence/tool-card classification, token economy core tools, and docs.
  • Steer bash tool usage toward move_file instead of shell mv / Move-Item for file moves.
  • Add regression coverage for execution, workspace confinement, and permission grant behavior.

Validation

  • go test ./...
  • go test . in desktop
  • git diff --check
  • Cross-compiled affected core package tests for Windows and Linux with go test -c

Not run: frontend npm test because npm is unavailable in the local environment.

@github-actions github-actions Bot added v2 Go rewrite (1.x) — main-v2 branch, active development desktop Wails desktop app (desktop/**) tui Terminal UI / CLI (internal/cli, internal/control) skills Skill system (internal/skill, internal/tool) agent Core agent loop (internal/agent, internal/control) config Configuration & setup (internal/config) labels Jun 13, 2026
@SivanCola SivanCola marked this pull request as ready for review June 13, 2026 17:17
@SivanCola SivanCola requested a review from esengine as a code owner June 13, 2026 17:17
@SivanCola

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c3ca2a026e

ℹ️ 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".

Comment thread internal/permission/permission.go
Comment thread internal/tool/builtin/movefile.go Outdated
Comment thread internal/tool/builtin/movefile.go Outdated
Comment thread internal/tool/builtin/movefile.go Outdated

Copy link
Copy Markdown
Collaborator Author

Pushed a follow-up fix for the Windows test failure in 31a2a5d9.

Root cause:

  • The case-only rename path can still fail on Windows because the destination casing variant may be treated as an existing target by os.Rename.

What changed:

  • When source and destination resolve to the same file and the direct rename fails, move_file now renames through a temporary file in the same directory, removing the same-file destination link before the final rename when needed.
  • Added regression coverage for the same-file destination fallback.

Verified locally:

  • go test ./internal/tool/builtin
  • GOOS=windows GOARCH=amd64 go build ./...
  • GOOS=windows GOARCH=amd64 go vet ./...
  • GOOS=windows GOARCH=amd64 go test -c ./internal/tool/builtin
  • go test ./...
  • git diff --check

SivanCola commented Jun 13, 2026

Copy link
Copy Markdown
Collaborator Author

Correction: #4316 remains the standalone move_file fix for #4310. #4319 is being kept separate for the PermissionRequest hook work from #3661/#3855 and should not supersede this PR.

@SivanCola SivanCola closed this Jun 13, 2026
@SivanCola SivanCola reopened this Jun 13, 2026
@SivanCola SivanCola enabled auto-merge June 13, 2026 18:18
@SivanCola

Copy link
Copy Markdown
Collaborator Author

approve

SivanCola commented Jun 13, 2026

Copy link
Copy Markdown
Collaborator Author

Pushed 2843b327 to fix the Windows CI failure.

Root cause:

  • The cross-device move_file fallback copied from the source and then tried to remove the source while the input file handle was still open. Unix permits removing an open file, but Windows rejects it with a file-in-use error.

What changed:

  • copyRegularFileAndRemoveSource now closes the source file handle after copying and closing the destination, before removing the source.

Verified locally:

  • go test ./internal/tool/builtin
  • REASONIX_RELEASE_CACHE_GUARD=1 go test ./...
  • go vet ./...
  • go build ./...
  • GOOS=windows GOARCH=amd64 go build ./...
  • GOOS=windows GOARCH=amd64 go vet ./...
  • Windows go test -c for ./internal/tool/builtin
  • git diff --check

GitHub Actions update:

  • CI run 6208 now passes, including test (windows-latest) and race.
  • CodeQL run 3703 also passes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent Core agent loop (internal/agent, internal/control) config Configuration & setup (internal/config) desktop Wails desktop app (desktop/**) skills Skill system (internal/skill, internal/tool) tui Terminal UI / CLI (internal/cli, internal/control) v2 Go rewrite (1.x) — main-v2 branch, active development

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: 在修改代码的过程中会频繁的索要权限,即便选择了“总是允许”

1 participant