MCPcopy Index your code
hub / github.com/OpenBMB/ChatDev / move_path

Function move_path

functions/function_calling/file.py:674–707  ·  view source on GitHub ↗

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,
)

Source from the content-addressed store, hash-verified

672
673
674def 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
710def search_in_files(

Callers

nothing calls this directly

Calls 6

to_workspace_relativeMethod · 0.95
ParamMetaClass · 0.90
FileToolContextClass · 0.85
_clear_destinationFunction · 0.85

Tested by

no test coverage detected