@@ -306,16 +306,35 @@ fn ensure_skill_symlinks(_root: &Path) -> Result<(), String> {
306306 Ok ( ( ) )
307307}
308308
309- /// Ensures `~/.local/bin/buzz` is a symlink to the bundled CLI binary .
309+ /// Returns the `~/.local/bin` link name for the bundled CLI.
310310///
311- /// On every boot: replaces any existing symlink unconditionally (the `buzz`
312- /// name is our namespace), creates a new one if absent, and leaves regular
313- /// files alone to avoid clobbering a user-compiled binary.
311+ /// Dev builds (`is_dev = true`) use `"buzz-dev"` so that a running DMG and a
312+ /// concurrent dev build each own a separate link and never clobber each other —
313+ /// the same isolation that separates `~/.buzz` (prod) from `~/.buzz-dev` (dev).
314+ pub fn cli_link_name ( is_dev : bool ) -> & ' static str {
315+ if is_dev {
316+ "buzz-dev"
317+ } else {
318+ "buzz"
319+ }
320+ }
321+
322+ /// Ensures `~/.local/bin/buzz` (prod) or `~/.local/bin/buzz-dev` (dev) is a
323+ /// symlink to the bundled CLI binary.
324+ ///
325+ /// The link name is split by `is_dev` so that an installed DMG and a
326+ /// concurrently running dev build each maintain their own symlink and never
327+ /// overwrite each other's target — the same isolation that separates the
328+ /// `~/.buzz` and `~/.buzz-dev` nests (see [`NEST_DIR_DEV`]).
329+ ///
330+ /// On every boot: replaces any existing symlink unconditionally (the `buzz` /
331+ /// `buzz-dev` name is our namespace), creates a new one if absent, and leaves
332+ /// regular files alone to avoid clobbering a user-compiled binary.
314333///
315334/// Non-fatal: callers should ignore errors — the symlink is a convenience
316335/// for human Terminal use; agents find the CLI via PATH augmentation.
317336#[ cfg( unix) ]
318- pub fn ensure_cli_symlink ( exe_parent : & Path ) -> Result < ( ) , String > {
337+ pub fn ensure_cli_symlink ( exe_parent : & Path , is_dev : bool ) -> Result < ( ) , String > {
319338 let buzz_bin = exe_parent. join ( "buzz" ) ;
320339 if !buzz_bin. exists ( ) {
321340 return Ok ( ( ) ) ; // CLI not bundled (e.g., dev builds without sidecars).
@@ -327,7 +346,7 @@ pub fn ensure_cli_symlink(exe_parent: &Path) -> Result<(), String> {
327346 . join ( "bin" ) ;
328347 fs:: create_dir_all ( & local_bin) . map_err ( |e| format ! ( "create {}: {e}" , local_bin. display( ) ) ) ?;
329348
330- let link = local_bin. join ( "buzz" ) ;
349+ let link = local_bin. join ( cli_link_name ( is_dev ) ) ;
331350 match link. symlink_metadata ( ) {
332351 Ok ( meta) if meta. file_type ( ) . is_symlink ( ) => {
333352 let _ = fs:: remove_file ( & link) ;
@@ -351,7 +370,7 @@ pub fn ensure_cli_symlink(exe_parent: &Path) -> Result<(), String> {
351370
352371/// No-op on non-Unix platforms — symlink management is macOS/Linux only.
353372#[ cfg( not( unix) ) ]
354- pub fn ensure_cli_symlink ( _exe_parent : & Path ) -> Result < ( ) , String > {
373+ pub fn ensure_cli_symlink ( _exe_parent : & Path , _is_dev : bool ) -> Result < ( ) , String > {
355374 Ok ( ( ) )
356375}
357376
@@ -983,38 +1002,87 @@ mod tests {
9831002 ) ;
9841003 }
9851004
1005+ #[ test]
1006+ fn cli_link_name_prod_is_buzz ( ) {
1007+ assert_eq ! ( cli_link_name( false ) , "buzz" ) ;
1008+ }
1009+
1010+ #[ test]
1011+ fn cli_link_name_dev_is_buzz_dev ( ) {
1012+ assert_eq ! ( cli_link_name( true ) , "buzz-dev" ) ;
1013+ }
1014+
9861015 #[ cfg( unix) ]
9871016 #[ test]
988- fn ensure_cli_symlink_creates_symlink ( ) {
1017+ fn ensure_cli_symlink_creates_symlink_prod ( ) {
9891018 let tmp = tempfile:: tempdir ( ) . unwrap ( ) ;
9901019 let exe_parent = tmp. path ( ) . join ( "MacOS" ) ;
9911020 fs:: create_dir ( & exe_parent) . unwrap ( ) ;
9921021 fs:: write ( exe_parent. join ( "buzz" ) , "binary" ) . unwrap ( ) ;
9931022
994- // Simulate the symlink creation path.
9951023 let local_bin = tmp. path ( ) . join ( "local_bin" ) ;
9961024 fs:: create_dir_all ( & local_bin) . unwrap ( ) ;
997- let link = local_bin. join ( "buzz" ) ;
9981025
1026+ // Prod link name is "buzz"; simulate the symlink creation path.
1027+ let link = local_bin. join ( cli_link_name ( false ) ) ;
9991028 std:: os:: unix:: fs:: symlink ( exe_parent. join ( "buzz" ) , & link) . unwrap ( ) ;
10001029 assert ! ( link. symlink_metadata( ) . unwrap( ) . file_type( ) . is_symlink( ) ) ;
10011030 assert_eq ! ( fs:: read_link( & link) . unwrap( ) , exe_parent. join( "buzz" ) ) ;
10021031 }
10031032
10041033 #[ cfg( unix) ]
10051034 #[ test]
1006- fn ensure_cli_symlink_does_not_clobber_regular_file ( ) {
1035+ fn ensure_cli_symlink_creates_symlink_dev ( ) {
10071036 let tmp = tempfile:: tempdir ( ) . unwrap ( ) ;
1037+ let exe_parent = tmp. path ( ) . join ( "MacOS" ) ;
1038+ fs:: create_dir ( & exe_parent) . unwrap ( ) ;
1039+ fs:: write ( exe_parent. join ( "buzz" ) , "binary" ) . unwrap ( ) ;
1040+
10081041 let local_bin = tmp. path ( ) . join ( "local_bin" ) ;
10091042 fs:: create_dir_all ( & local_bin) . unwrap ( ) ;
1010- let link = local_bin. join ( "buzz" ) ;
1043+
1044+ // Dev link must be "buzz-dev", never "buzz".
1045+ assert_eq ! ( cli_link_name( true ) , "buzz-dev" ) ;
1046+
1047+ let link = local_bin. join ( cli_link_name ( true ) ) ;
1048+ std:: os:: unix:: fs:: symlink ( exe_parent. join ( "buzz" ) , & link) . unwrap ( ) ;
1049+ assert ! ( link. symlink_metadata( ) . unwrap( ) . file_type( ) . is_symlink( ) ) ;
1050+ assert_eq ! ( fs:: read_link( & link) . unwrap( ) , exe_parent. join( "buzz" ) ) ;
1051+ // Prod link must not exist — the two builds don't touch each other.
1052+ assert ! ( !local_bin. join( "buzz" ) . exists( ) ) ;
1053+ }
1054+
1055+ #[ cfg( unix) ]
1056+ #[ test]
1057+ fn ensure_cli_symlink_does_not_clobber_regular_file_prod ( ) {
1058+ let tmp = tempfile:: tempdir ( ) . unwrap ( ) ;
1059+ let local_bin = tmp. path ( ) . join ( "local_bin" ) ;
1060+ fs:: create_dir_all ( & local_bin) . unwrap ( ) ;
1061+ let link = local_bin. join ( cli_link_name ( false ) ) ;
10111062 fs:: write ( & link, "user-installed binary" ) . unwrap ( ) ;
10121063
10131064 // Regular files are preserved — the Ok(_) branch skips them.
10141065 assert ! ( link. symlink_metadata( ) . unwrap( ) . file_type( ) . is_file( ) ) ;
10151066 assert_eq ! ( fs:: read_to_string( & link) . unwrap( ) , "user-installed binary" ) ;
10161067 }
10171068
1069+ #[ cfg( unix) ]
1070+ #[ test]
1071+ fn ensure_cli_symlink_does_not_clobber_regular_file_dev ( ) {
1072+ let tmp = tempfile:: tempdir ( ) . unwrap ( ) ;
1073+ let local_bin = tmp. path ( ) . join ( "local_bin" ) ;
1074+ fs:: create_dir_all ( & local_bin) . unwrap ( ) ;
1075+ let link = local_bin. join ( cli_link_name ( true ) ) ;
1076+ fs:: write ( & link, "user-installed buzz-dev binary" ) . unwrap ( ) ;
1077+
1078+ // Regular files at the dev path are also preserved.
1079+ assert ! ( link. symlink_metadata( ) . unwrap( ) . file_type( ) . is_file( ) ) ;
1080+ assert_eq ! (
1081+ fs:: read_to_string( & link) . unwrap( ) ,
1082+ "user-installed buzz-dev binary"
1083+ ) ;
1084+ }
1085+
10181086 fn make_persona ( id : & str , display_name : & str ) -> PersonaRecord {
10191087 PersonaRecord {
10201088 id : id. to_string ( ) ,
0 commit comments