Skip to main content

Module fs

Module fs 

Source
Expand description

Filesystem tools for the tcode tool registry.

Why: AI coding loops (e.g. the ai-coding-bake-off L1 agentic loop) need the agent to create, read, and patch files on the host filesystem. Providing typed ToolExecutor implementations instead of raw shell-exec keeps error handling structured, scoping to a working directory enforced, and path traversal impossible. What: ToolExecutor impls for the engineer’s filesystem surface — ReadFileTool, WriteFileTool, EditTool, plus the batch-write and exploration tools WriteFilesTool (#2681), GlobTool, GrepTool, and ListDirTool (#1027) — each with an OpenAI-function-call schema and registration helpers. EditTool (#2068) supports three edit wire formats — SEARCH/REPLACE, unified-diff, and whole-file — selected per-model via edit_format. The exploration tools give the engineer native file discovery so it no longer shells out to find/grep/ls (the dominant bake-off agent-turn sink). Errors use thiserror for clean structured error types. Test: read.rs, write.rs, write_files.rs, glob.rs, grep.rs, list_dir.rs, and edit.rs each carry tempdir-based unit tests; edit_format carries its own matrix/application tests; registry_tests verifies the tools appear in schemas() and dispatch through dispatch_gated.

Re-exports§

pub use edit::EditTool;
pub use glob::GlobTool;
pub use grep::GrepTool;
pub use list_dir::ListDirTool;
pub use read::ReadFileTool;
pub use write::WriteFileTool;
pub use write_files::WRITE_FILES_TOOL_NAME;
pub use write_files::WriteFilesTool;

Modules§

edit
edit tool — per-model edit-format selection (#2068).
edit_format
Per-model edit-format selection for the edit tool (#2068, P1B-1).
glob
glob tool — find files by glob pattern (e.g. **/*.py, src/*.rs).
grep
grep tool — search file contents by regex across the project.
list_dir
list_dir tool — list the entries of a single directory.
read
read_file tool — read file contents, optionally limited to a line range.
write
write_file tool — create or overwrite a file, creating parent dirs as needed.
write_files
write_files tool — create or overwrite MANY files in a single call.

Enums§

FsError
Errors produced by filesystem tools.