Skip to main content

Crate patchloom

Crate patchloom 

Source
Expand description

Patchloom: agent-grade repo operations as a Rust library.

This crate provides both a CLI binary and a library API for structured file editing operations. The api module is the main entry point for library consumers.

§Feature flags

FeatureDefaultDescription
corenoMarker feature for core library usage (no extra deps)
mcpyesMCP server support (adds tokio, rmcp, schemars)
fullnoEverything: currently equivalent to mcp

§Embedding as a library

To use patchloom as a library without the MCP server overhead:

[dependencies]
patchloom = { version = "0.1", default-features = false }

This gives you the full api module (doc/replace/md/file/patch operations) and the ops module for lower-level access, without pulling in tokio or other async runtime dependencies.

§Thread safety

All public API types (api::EditResult, api::ApplyMode, etc.) are Send + Sync. Library functions are safe to call concurrently from multiple threads with one constraint:

  • Different files: fully safe. Multiple threads can edit different files simultaneously with no coordination.
  • Same file: the caller must serialize access. Concurrent writes to the same file are inherently racy (last writer wins). Use a mutex or other synchronization if you need to coordinate edits to a single file.

Backup sessions use unique directory names (nanosecond timestamp + monotonic counter) so concurrent backup creation never collides.

Configuration can be loaded once with config::CachedConfig and reused across threads, avoiding repeated disk reads.

Modules§

api
Public library API for embedding patchloom in Rust applications.
backup
Backup session management for undo safety net.
cli
cmd
config
Project configuration file support (.patchloom.toml).
diff
Unified diff generation and rendering.
exit
fallback
Multi-strategy fallback chain for edit resolution.
ops
plan
Transaction plan format parsing.
schema
Intent format specification with versioning, tier filtering, and schema export.
selector
write
Atomic write, final newline, EOL normalization, trailing-whitespace trimming.

Macros§

verbose
Print a verbose diagnostic message to stderr.

Functions§

is_verbose
Returns true if verbose mode is enabled.
run
Run the patchloom CLI. Returns the exit code as a u8.