Skip to main content

Crate rpi_tools

Crate rpi_tools 

Source
Expand description

Mirrors packages/agent/src/harness (tools + env + session + compaction).

M4 scope: ExecutionEnv trait + OsExecutionEnv + InMemoryExecutionEnv + file-mutation-queue + read/write/edit/bash tools + edit-diff + utils (truncate, shell-output, image, path-utils). Session/compaction arrive in M5 (these live in pi-harness, not here).

Workspace dep chain: pi-telemetry → pi-ai → pi-agent → pi-tools → pi-harness → pi-cli. pi-tools depends on pi-agent (for the AgentTool trait) and pi-ai (for Tool/content types).

Re-exports§

pub use tools::create_bash_tool;
pub use tools::create_edit_tool;
pub use tools::create_find_tool;
pub use tools::create_grep_tool;
pub use tools::create_ls_tool;
pub use tools::create_powershell_tool;
pub use tools::create_read_tool;
pub use tools::create_write_tool;
pub use tools::BashExecution;
pub use tools::BashPrepare;
pub use tools::BashToolOptions;
pub use tools::ExecutionToolContext;
pub use tools::ProcessedImage;
pub use tools::ReadImageProcessor;
pub use tools::ReadToolOptions;
pub use env::ExecutionEnv;
pub use env::FileContent;
pub use env::FileInfo;
pub use env::FileKind;
pub use env::FileSystem;
pub use env::Shell;
pub use env::ShellExecOptions;
pub use env::ShellOutput;
pub use error::io_to_file_code;
pub use error::io_to_file_error;
pub use error::ExecutionError;
pub use error::ExecutionErrorCode;
pub use error::FileError;
pub use error::FileErrorCode;
pub use file_mutation_queue::get_mutation_queue_key;
pub use file_mutation_queue::with_file_mutation_queue;
pub use file_mutation_queue::MutatingEnv;
pub use file_mutation_queue::MutationQueueRegistry;
pub use image::detect_supported_image_mime_type;
pub use image::encode_base64;
pub use in_memory::InMemoryExecutionEnv;
pub use in_memory::ShellScript;
pub use os_env::is_host_private_env;
pub use os_env::OsExecutionEnv;
pub use os_env::HOST_PRIVATE_ENV;
pub use path_utils::normalize_tool_path;
pub use path_utils::resolve_read_tool_path;
pub use path_utils::resolve_tool_path;
pub use truncate::format_size;
pub use truncate::split_lines_for_counting;
pub use truncate::truncate_head;
pub use truncate::truncate_line;
pub use truncate::truncate_tail;
pub use truncate::TruncateLineOutput;
pub use truncate::TruncationLimit;
pub use truncate::TruncationOptions;
pub use truncate::TruncationResult;
pub use truncate::DEFAULT_MAX_BYTES;
pub use truncate::DEFAULT_MAX_LINES;
pub use truncate::GREP_MAX_LINE_LENGTH;

Modules§

env
Mirrors packages/agent/src/harness/types.ts::ExecutionEnv — the trait every tool and test-double implements. ExecutionEnv = FileSystem + Shell.
error
Mirrors packages/agent/src/harness/types.ts — the FileError / ExecutionError shapes + their stable code enums used by the ExecutionEnv trait. Drops the TS ok/err/getOrThrow helpers (Rust has these natively) and the CompactionError/BranchSummaryError (those live in pi-harness).
file_mutation_queue
Mirrors packages/agent/src/harness/tools/file-mutation-queue.ts — serializes file-mutating operations per canonical path so concurrent edits to the same path (or a symlink + its target) don’t interleave.
image
Mirrors packages/agent/src/harness/tools/image.ts — image MIME detection from byte signatures and base64 encoding.
image_processing
Image processing utilities — resize, convert, and transform images.
in_memory
InMemoryExecutionEnv — an in-memory ExecutionEnv for tests. NOT a direct mirror of a single TS file (the TS harness has no in-memory env; it tests against NodeExecutionEnv + tempdirs). This is the Rust port’s primary test double, modeled to satisfy the same FileSystem + Shell contract so the conformance suite can run identical assertions against both InMemory and Os.
os_env
Mirrors packages/agent/src/harness/env/nodejs.ts — NodeExecutionEnv → OsExecutionEnv. Real-filesystem + real-process backend via tokio::fs + tokio::process.
path_utils
Mirrors packages/agent/src/harness/tools/path-utils.ts — tool-path normalization + resolution, including the read tool’s fuzzy-existence lookup of typographic variants the model commonly emits.
shell_output
Mirrors packages/agent/src/harness/utils/shell-output.ts — the bash tool’s output-capture layer wrapping Shell::exec.
tools
Mirrors packages/agent/src/harness/tools/* — the built-in read/write/ edit/bash AgentTool impls + the read-only grep/find/ls ports (port of packages/coding-agent/src/core/tools/{grep,find,ls}.ts) + their shared helpers.
truncate
Mirrors packages/agent/src/harness/utils/truncate.ts — head/tail line+byte truncation with structured metadata. Used by the read tool (head) and the bash tool’s execute_shell_with_capture (tail).
utils