1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
//! 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
//!
//! | Feature | Default | Description |
//! |---------|---------|-------------|
//! | `core` | no | Marker feature for core library usage (no extra deps) |
//! | `mcp` | **yes** | MCP server support (adds `tokio`, `rmcp`, `schemars`) |
//! | `full` | no | Everything: currently equivalent to `mcp` |
//!
//! ## Embedding as a library
//!
//! To use patchloom as a library without the MCP server overhead:
//!
//! ```toml
//! [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.
pub
pub use *;
use Parser;
use Cli;
// ---------------------------------------------------------------------------
// Verbose logging
// ---------------------------------------------------------------------------
/// Global flag set once at startup; checked by the `verbose!` macro.
static VERBOSE: AtomicBool = new;
/// Returns `true` if verbose mode is enabled.
/// Enable verbose mode globally. Called once at startup.
/// Print a verbose diagnostic message to stderr.
///
/// Usage: `verbose!("processing {} files", count);`
/// Run the patchloom CLI. Returns the exit code as a u8.