Move files or directories, mirroring `mv` semantics across platforms.
(
src: Annotated[str, ParamMeta(description="Source workspace-relative path")],
dst: Annotated[str, ParamMeta(description="Destination workspace-relative path")],
*,
overwrite: Annotated[
bool,
ParamMeta(description="Allow replacing destination path"),
] = False,
_context: Dict[str, Any] | None = None,
)
| 672 | |
| 673 | |
| 674 | def move_path( |
| 675 | src: Annotated[str, ParamMeta(description="Source workspace-relative path")], |
| 676 | dst: Annotated[str, ParamMeta(description="Destination workspace-relative path")], |
| 677 | *, |
| 678 | overwrite: Annotated[ |
| 679 | bool, |
| 680 | ParamMeta(description="Allow replacing destination path"), |
| 681 | ] = False, |
| 682 | _context: Dict[str, Any] | None = None, |
| 683 | ) -> Dict[str, Any]: |
| 684 | """Move files or directories, mirroring `mv` semantics across platforms.""" |
| 685 | |
| 686 | ctx = FileToolContext(_context) |
| 687 | source = ctx.resolve_under_workspace(src) |
| 688 | destination = ctx.resolve_under_workspace(dst) |
| 689 | _check_attachments_not_modified(src) |
| 690 | _check_attachments_not_modified(dst) |
| 691 | |
| 692 | if not source.exists(): |
| 693 | raise FileNotFoundError(f"Source does not exist: {src}") |
| 694 | if source == destination: |
| 695 | return { |
| 696 | "path": ctx.to_workspace_relative(destination), |
| 697 | "operation": "move", |
| 698 | "skipped": True, |
| 699 | } |
| 700 | _clear_destination(destination, overwrite) |
| 701 | destination.parent.mkdir(parents=True, exist_ok=True) |
| 702 | shutil.move(source, destination) |
| 703 | return { |
| 704 | "path": ctx.to_workspace_relative(destination), |
| 705 | "source": ctx.to_workspace_relative(source), |
| 706 | "operation": "move", |
| 707 | } |
| 708 | |
| 709 | |
| 710 | def search_in_files( |
nothing calls this directly
no test coverage detected