@@ -265,9 +265,9 @@ fn ensure_skill_symlinks(_root: &Path) -> Result<(), String> {
265265
266266/// Ensures `~/.local/bin/buzz` is a symlink to the bundled CLI binary.
267267///
268- /// Creates the symlink if it doesn't exist, updates it if it already points
269- /// to a Buzz app bundle, and leaves it alone if it points elsewhere (to
270- /// avoid clobbering another tool's binary) .
268+ /// On every boot: replaces any existing symlink unconditionally (the `buzz`
269+ /// name is our namespace), creates a new one if absent, and leaves regular
270+ /// files alone to avoid clobbering a user-compiled binary.
271271///
272272/// Non-fatal: callers should ignore errors — the symlink is a convenience
273273/// for human Terminal use; agents find the CLI via PATH augmentation.
@@ -287,23 +287,14 @@ pub fn ensure_cli_symlink(exe_parent: &Path) -> Result<(), String> {
287287 let link = local_bin. join ( "buzz" ) ;
288288 match link. symlink_metadata ( ) {
289289 Ok ( meta) if meta. file_type ( ) . is_symlink ( ) => {
290- // Symlink exists — only update if it points to a Buzz bundle.
291- if let Ok ( target) = fs:: read_link ( & link) {
292- let target_str = target. display ( ) . to_string ( ) ;
293- if target_str. contains ( ".app/Contents/MacOS" ) {
294- // Buzz-owned symlink — update to current bundle path.
295- let _ = fs:: remove_file ( & link) ;
296- std:: os:: unix:: fs:: symlink ( & buzz_bin, & link)
297- . map_err ( |e| format ! ( "symlink {}: {e}" , link. display( ) ) ) ?;
298- }
299- // Otherwise: symlink points elsewhere — don't clobber.
300- }
290+ let _ = fs:: remove_file ( & link) ;
291+ std:: os:: unix:: fs:: symlink ( & buzz_bin, & link)
292+ . map_err ( |e| format ! ( "symlink {}: {e}" , link. display( ) ) ) ?;
301293 }
302294 Ok ( _) => {
303295 // Regular file or directory — don't clobber.
304296 }
305297 Err ( e) if e. kind ( ) == std:: io:: ErrorKind :: NotFound => {
306- // No file exists — create the symlink.
307298 std:: os:: unix:: fs:: symlink ( & buzz_bin, & link)
308299 . map_err ( |e| format ! ( "symlink {}: {e}" , link. display( ) ) ) ?;
309300 }
@@ -935,13 +926,11 @@ mod tests {
935926 fs:: create_dir ( & exe_parent) . unwrap ( ) ;
936927 fs:: write ( exe_parent. join ( "buzz" ) , "binary" ) . unwrap ( ) ;
937928
938- // Point home_dir to a temp location by using ensure_cli_symlink
939- // directly with a custom link target. We'll test the logic manually.
929+ // Simulate the symlink creation path.
940930 let local_bin = tmp. path ( ) . join ( "local_bin" ) ;
941931 fs:: create_dir_all ( & local_bin) . unwrap ( ) ;
942932 let link = local_bin. join ( "buzz" ) ;
943933
944- // Create symlink manually to test the creation path.
945934 std:: os:: unix:: fs:: symlink ( exe_parent. join ( "buzz" ) , & link) . unwrap ( ) ;
946935 assert ! ( link. symlink_metadata( ) . unwrap( ) . file_type( ) . is_symlink( ) ) ;
947936 assert_eq ! ( fs:: read_link( & link) . unwrap( ) , exe_parent. join( "buzz" ) ) ;
@@ -956,11 +945,8 @@ mod tests {
956945 let link = local_bin. join ( "buzz" ) ;
957946 fs:: write ( & link, "user-installed binary" ) . unwrap ( ) ;
958947
959- // Verify it's a regular file .
948+ // Regular files are preserved — the Ok(_) branch skips them .
960949 assert ! ( link. symlink_metadata( ) . unwrap( ) . file_type( ) . is_file( ) ) ;
961- // Content should be preserved (we can't call ensure_cli_symlink
962- // directly without controlling dirs::home_dir(), but the logic
963- // in the Ok(_) branch of ensure_cli_symlink skips regular files).
964950 assert_eq ! ( fs:: read_to_string( & link) . unwrap( ) , "user-installed binary" ) ;
965951 }
966952
0 commit comments