Initialize checkpoint manager manually
(
os: &Os,
path: impl AsRef<Path>,
current_history: &VecDeque<HistoryEntry>,
)
| 101 | |
| 102 | /// Initialize checkpoint manager manually |
| 103 | pub async fn manual_init( |
| 104 | os: &Os, |
| 105 | path: impl AsRef<Path>, |
| 106 | current_history: &VecDeque<HistoryEntry>, |
| 107 | ) -> Result<Self> { |
| 108 | let path = path.as_ref(); |
| 109 | os.fs.create_dir_all(path).await?; |
| 110 | |
| 111 | let work_tree_path = |
| 112 | std::env::current_dir().map_err(|e| eyre!("Failed to get current working directory: {}", e))?; |
| 113 | |
| 114 | // Initialize bare repository |
| 115 | run_git(path, None, &["init", "--bare", &path.to_string_lossy()])?; |
| 116 | |
| 117 | // Configure git |
| 118 | configure_git(&path.to_string_lossy())?; |
| 119 | |
| 120 | // Create initial checkpoint |
| 121 | stage_commit_tag(&path.to_string_lossy(), &work_tree_path, "Initial state", "0")?; |
| 122 | |
| 123 | let initial_checkpoint = Checkpoint { |
| 124 | tag: "0".to_string(), |
| 125 | timestamp: Local::now(), |
| 126 | description: "Initial state".to_string(), |
| 127 | history_snapshot: current_history.clone(), |
| 128 | is_turn: true, |
| 129 | tool_name: None, |
| 130 | }; |
| 131 | |
| 132 | let mut tag_index = HashMap::new(); |
| 133 | tag_index.insert("0".to_string(), 0); |
| 134 | |
| 135 | Ok(Self { |
| 136 | shadow_repo_path: path.to_path_buf(), |
| 137 | work_tree_path, |
| 138 | checkpoints: vec![initial_checkpoint], |
| 139 | tag_index, |
| 140 | current_turn: 0, |
| 141 | tools_in_turn: 0, |
| 142 | pending_user_message: None, |
| 143 | message_locked: false, |
| 144 | file_stats_cache: HashMap::new(), |
| 145 | }) |
| 146 | } |
| 147 | |
| 148 | /// Create a new checkpoint point |
| 149 | pub fn create_checkpoint( |
nothing calls this directly
no test coverage detected