On this page
Write tool constructors: write, edit, multi_edit, mkdir, move, copy, delete (wraps saferm), and set_executable -- all enforcing write-scope containment, with write/edit routed through write-safety's queue and stale-write tracker.
#tool.src.orxtra.tool._write_tools
#tool.src.orxtra.tool._write_tools
File write tool constructors for the orxtra tool module.
#_path_error_to_tool_error
def _path_error_to_tool_error(exc: PathError) -> ToolErrorConvert a PathError to a ToolError.
#_resolve_path
def _resolve_path(raw_path: str, root: Path) -> PathResolve a path, converting PathError to ToolError.
#_check_scope
def _check_scope(resolved: Path, scope: list[Path] | None, root: Path) -> NoneCheck write scope, converting PathError to ToolError.
#make_write_tool
def make_write_tool(read_root: Path, write_scope: list[Path] | None, queue: WriteQueue, tracker: StaleWriteTracker, session_id: str) -> ToolConstruct the file write tool.
Args:
read_root: Root directory for path containment.write_scope: Allowed write paths, or None for unrestricted.queue: Per-path write queue for serialization.tracker: Stale-write detector.session_id: The session performing writes.
#make_edit_tool
def make_edit_tool(read_root: Path, write_scope: list[Path] | None, queue: WriteQueue, tracker: StaleWriteTracker, session_id: str) -> ToolConstruct the find-and-replace edit tool.
Args:
read_root: Root directory for path containment.write_scope: Allowed write paths, or None for unrestricted.queue: Per-path write queue for serialization.tracker: Stale-write detector.session_id: The session performing writes.
#make_multi_edit_tool
def make_multi_edit_tool(read_root: Path, write_scope: list[Path] | None, queue: WriteQueue, tracker: StaleWriteTracker, session_id: str) -> ToolConstruct the multi-edit tool for batched find-and-replace edits.
Applies edits sequentially. If any edit fails, the result reports which edits succeeded and which failed (no atomic rollback).
Args:
read_root: Root directory for path containment.write_scope: Allowed write paths, or None for unrestricted.queue: Per-path write queue for serialization.tracker: Stale-write detector.session_id: The session performing writes.
#make_mkdir_tool
def make_mkdir_tool(read_root: Path, write_scope: list[Path] | None) -> ToolConstruct the mkdir tool.
Args:
read_root: Root directory for path containment.write_scope: Allowed write paths, or None for unrestricted.
#make_move_tool
def make_move_tool(read_root: Path, write_scope: list[Path] | None, queue: WriteQueue, tracker: StaleWriteTracker, session_id: str) -> ToolConstruct the move/rename tool.
Args:
read_root: Root directory for path containment.write_scope: Allowed write paths, or None for unrestricted.queue: Per-path write queue for serialization.tracker: Stale-write detector.session_id: The session performing writes.
#make_copy_tool
def make_copy_tool(read_root: Path, write_scope: list[Path] | None, queue: WriteQueue, tracker: StaleWriteTracker, session_id: str) -> ToolConstruct the file copy tool.
Args:
read_root: Root directory for path containment.write_scope: Allowed write paths, or None for unrestricted.queue: Per-path write queue for serialization.tracker: Stale-write detector.session_id: The session performing writes.
#make_delete_tool
def make_delete_tool(read_root: Path, write_scope: list[Path] | None) -> ToolConstruct the delete tool (wraps saferm).
Args:
read_root: Root directory for path containment.write_scope: Allowed write paths, or None for unrestricted.
#make_set_executable_tool
def make_set_executable_tool(read_root: Path, write_scope: list[Path] | None) -> ToolConstruct the set-executable tool.
Args:
read_root: Root directory for path containment.write_scope: Allowed write paths, or None for unrestricted.