4848//! # Ok::<(), anyhow::Error>(())
4949//! ```
5050
51- use anyhow:: { Context , Result } ;
51+ use anyhow:: Result ;
5252use std:: path:: PathBuf ;
5353
5454/// Explicit storage strategy for checkpoints
@@ -188,8 +188,8 @@ impl CheckpointStorage {
188188
189189/// Pure function: get global Prodigy storage directory
190190///
191- /// Returns `~/.prodigy` as the base directory for all global Prodigy storage.
192- /// This is a pure function that derives the path from system home directory .
191+ /// Returns the base directory for all global Prodigy storage.
192+ /// Respects the PRODIGY_HOME environment variable for testing and custom configurations .
193193///
194194/// # Errors
195195///
@@ -201,12 +201,12 @@ impl CheckpointStorage {
201201/// use prodigy::cook::workflow::checkpoint_path::resolve_global_base_dir;
202202///
203203/// let base = resolve_global_base_dir()?;
204- /// assert!(base.to_string_lossy().ends_with (".prodigy"));
204+ /// assert!(base.to_string_lossy().contains (".prodigy") || std::env::var("PRODIGY_HOME").is_ok( ));
205205/// # Ok::<(), anyhow::Error>(())
206206/// ```
207207pub fn resolve_global_base_dir ( ) -> Result < PathBuf > {
208- let base_dirs = directories :: BaseDirs :: new ( ) . context ( "Could not determine home directory" ) ? ;
209- Ok ( base_dirs . home_dir ( ) . join ( ".prodigy" ) )
208+ // Delegate to centralized storage function that respects PRODIGY_HOME
209+ crate :: storage :: get_default_storage_dir ( )
210210}
211211
212212#[ cfg( test) ]
@@ -230,9 +230,10 @@ mod tests {
230230 } ;
231231
232232 let base = storage. resolve_base_dir ( ) . unwrap ( ) ;
233+ // Check relative path structure (works with both ~/.prodigy and PRODIGY_HOME)
233234 assert ! ( base
234235 . to_string_lossy( )
235- . ends_with( ".prodigy/ state/test-session-123/checkpoints" ) ) ;
236+ . ends_with( "state/test-session-123/checkpoints" ) ) ;
236237
237238 let file = storage. checkpoint_file_path ( "checkpoint-1" ) . unwrap ( ) ;
238239 assert ! ( file
@@ -247,9 +248,10 @@ mod tests {
247248 } ;
248249
249250 let base = storage. resolve_base_dir ( ) . unwrap ( ) ;
251+ // Check relative path structure (works with both ~/.prodigy and PRODIGY_HOME)
250252 assert ! ( base
251253 . to_string_lossy( )
252- . ends_with( ".prodigy/ state/my-repo/checkpoints" ) ) ;
254+ . ends_with( "state/my-repo/checkpoints" ) ) ;
253255 }
254256
255257 #[ test]
@@ -259,9 +261,10 @@ mod tests {
259261 } ;
260262
261263 let base = storage. resolve_base_dir ( ) . unwrap ( ) ;
264+ // Check relative path structure (works with both ~/.prodigy and PRODIGY_HOME)
262265 assert ! ( base
263266 . to_string_lossy( )
264- . ends_with( ".prodigy/ sessions/test-session-456" ) ) ;
267+ . ends_with( "sessions/test-session-456" ) ) ;
265268
266269 let file = storage. checkpoint_file_path ( "ignored-id" ) . unwrap ( ) ;
267270 assert ! ( file. to_string_lossy( ) . ends_with( "/checkpoint.json" ) ) ;
@@ -330,9 +333,11 @@ mod tests {
330333 }
331334
332335 #[ test]
333- fn test_global_base_dir_contains_prodigy ( ) {
336+ fn test_global_base_dir_resolution ( ) {
337+ // Should return a valid path (may be PRODIGY_HOME or ~/.prodigy)
334338 let base = resolve_global_base_dir ( ) . unwrap ( ) ;
335- assert ! ( base. to_string_lossy( ) . ends_with( ".prodigy" ) ) ;
339+ // Just verify it's a non-empty path
340+ assert ! ( !base. as_os_str( ) . is_empty( ) ) ;
336341 }
337342
338343 #[ test]
0 commit comments