Skip to main content

Module write

Module write 

Source
Expand description

write_file tool — create or overwrite a file, creating parent dirs as needed.

Why: AI coding loops must be able to emit new source files. A structured ToolExecutor with explicit working-directory scoping is safer than a raw shell echo > or cat > call: path traversal is blocked at the tool boundary before anything touches the filesystem. What: WriteFileTool writes content to path (relative or absolute within working_dir), creating all missing parent directories. Existing files are overwritten atomically. Test: See #[cfg(test)] below — covers new file, parent dir creation, overwrite, and path traversal.

Structs§

WriteFileTool
ToolExecutor that creates or overwrites a file.