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. On success it also best-effort fires a mid-task incremental trusty-search index update for the written path (issue: mid-task incremental re-indexing) so search_code sees code written during the task, not just what existed at task start. Test: See #[cfg(test)] below — covers new file, parent dir creation, overwrite, and path traversal.

Structs§

WriteFileTool
ToolExecutor that creates or overwrites a file.