Skip to main content

ralph_workflow/files/io/
mod.rs

1//! File I/O operations for Ralph's agent files.
2//!
3//! This module handles basic file input/output operations:
4//! - Agent directory management (.agent/)
5//! - Commit message file operations
6//! - Context cleanup and file operations
7//! - Error recovery for file operations
8//! - File integrity and atomic writes
9//! - PROMPT.md backup management
10//!
11//! # Submodules
12//!
13//! - [`integrity`] - File integrity and atomic writes
14//! - [`recovery`] - Error recovery and state repair
15//! - [`context`] - Context file management (STATUS.md, NOTES.md, ISSUES.md)
16//! - [`agent_files`] - Agent file operations (`ensure_files`, commit message, etc.)
17//! - [`backup`] - PROMPT.md backup and read-only protection
18//!
19//! # File Operations
20//!
21//! All file operations should go through the `Workspace` trait for testability.
22//! See `crate::workspace` for the `Workspace` trait and `MemoryWorkspace` for testing.
23
24pub(in crate::files) mod integrity;
25pub(in crate::files) mod recovery;
26
27pub mod agent_files;
28pub mod backup;
29pub mod context;
30
31// Re-exports for backward compatibility
32pub use agent_files::{
33    cleanup_generated_files_with_workspace, delete_commit_message_file_with_workspace,
34    delete_plan_file_with_workspace, ensure_files_with_workspace, file_contains_marker,
35    file_contains_marker_with_workspace, read_commit_message_file_with_workspace,
36    setup_xsd_schemas_with_workspace, write_commit_message_file_with_workspace, GENERATED_FILES,
37};
38
39pub use integrity::{
40    check_and_cleanup_xml_before_retry_with_workspace, check_filesystem_ready_with_workspace,
41    check_xml_file_writable_with_workspace, cleanup_stale_xml_files_with_workspace,
42    verify_file_not_corrupted_with_workspace, write_file_atomic_with_workspace,
43};
44
45pub use backup::{
46    create_prompt_backup, create_prompt_backup_with_workspace, make_prompt_read_only,
47    make_prompt_read_only_with_workspace, make_prompt_writable,
48    make_prompt_writable_with_workspace, write_diff_backup_with_workspace,
49};
50
51pub use context::{
52    clean_context_for_reviewer, clean_context_for_reviewer_with_workspace,
53    delete_issues_file_for_isolation, delete_issues_file_for_isolation_with_workspace,
54    reset_context_for_isolation, update_status, update_status_with_workspace,
55};
56
57pub use recovery::{auto_repair, auto_repair_with_workspace, RecoveryStatus, StateValidation};