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
//! # WLK - File-Centric Version Control System
//!
//! WLK (Walkabout) is a file-centric, event-sourced version control system with implicit branching.
//! Unlike traditional VCS that track repository-level snapshots, WLK tracks each file independently
//! with its own complete delta history.
//!
//! ## Key Features
//!
//! - **File-Centric Architecture**: Each file has its own shadow file containing complete history
//! - **Implicit Branching**: Rewind to any point and edit - a new branch is created automatically
//! - **Event-Sourced**: All changes are stored as a sequence of delta operations
//! - **Per-File Branching**: Each file can have multiple parallel histories independently
//! - **Crash-Safe**: Write-ahead log ensures atomic operations
//! - **Human-Readable**: Shadow files are JSON for easy inspection
//!
//! ## Quick Example
//!
//! ```rust,no_run
//! use wlk::{Repository, DeltaOperation, ShadowFile};
//! use std::fs;
//! use std::path::Path;
//!
//! # fn main() -> anyhow::Result<()> {
//! // Initialize repository
//! let mut repo = Repository::init(Path::new("."))?;
//!
//! // Create and track a file
//! fs::write("example.txt", "Hello, World!")?;
//! repo.track_file(Path::new("example.txt"))?;
//!
//! // Make changes
//! fs::write("example.txt", "Hello, WLK!")?;
//!
//! // Create snapshot
//! let shadow_path = ShadowFile::shadow_path(Path::new("example.txt"))?;
//! let mut shadow = ShadowFile::load(&shadow_path)?;
//! let content = fs::read_to_string("example.txt")?;
//! shadow.apply_delta(
//! DeltaOperation::Snapshot { content },
//! Some("Updated greeting".to_string()),
//! )?;
//! shadow.save(&shadow_path)?;
//!
//! // View history
//! let history = shadow.get_history();
//! println!("Total versions: {}", history.len());
//! # Ok(())
//! # }
//! ```
//!
//! ## Architecture
//!
//! ### Shadow Files
//!
//! Each tracked file `foo.rs` has a corresponding shadow file `.wlk/foo.rs.wlk` that stores:
//! - Initial snapshot
//! - All delta operations (Insert, Delete, Replace, Snapshot)
//! - Parent-child relationships forming a delta tree
//! - Current HEAD pointer
//!
//! ### Delta Operations
//!
//! - `Insert`: Add text at position
//! - `Delete`: Remove text from range
//! - `Replace`: Replace range with new text
//! - `Snapshot`: Create full checkpoint
//!
//! ### Implicit Branching
//!
//! ```text
//! d0 (initial)
//! ├─ d-abc (feature A)
//! │ └─ d-def (refined A)
//! └─ d-xyz (feature B) ← Just rewind and edit!
//! ```
//!
//! ## Modules
//!
//! - [`delta`]: Delta operation definitions and application
//! - [`shadow`]: Shadow file management and delta tree
//! - [`repository`]: Repository initialization and file tracking
//! - [`config`]: Configuration management
//! - [`diff`]: Text diffing utilities
//! - [`utils`]: Helper functions
// Re-export commonly used types
pub use Config;
pub use ;
pub use ;
pub use ;
pub use ShadowFile;