@@ -11,9 +11,10 @@ async fn test_fetch_custom_registry() {
1111 let registry_path = PathBuf :: from ( "tests/fixtures/test-registry.json" ) ;
1212 let registry = fetch_registry ( & cache_dir, None , Some ( & registry_path) ) . await . unwrap ( ) ;
1313
14- assert_eq ! ( registry. agents. len( ) , 2 ) ;
14+ assert_eq ! ( registry. agents. len( ) , 3 ) ;
1515 assert_eq ! ( registry. agents[ 0 ] . id, "test-npx-agent" ) ;
1616 assert_eq ! ( registry. agents[ 1 ] . id, "test-binary-agent" ) ;
17+ assert_eq ! ( registry. agents[ 2 ] . id, "test-versioned-npx-agent" ) ;
1718}
1819
1920#[ tokio:: test]
@@ -95,4 +96,27 @@ async fn test_binary_caching() {
9596 let binary_path3 = download_binary ( & agent, binary_dist, & cache_dir, Some ( & ForceOption :: Binary ) ) . await . unwrap ( ) ;
9697 assert_eq ! ( path1, binary_path3) ;
9798 }
99+ }
100+
101+ #[ test]
102+ fn test_versioned_package_handling ( ) {
103+ // Test that versioned packages don't get @latest appended
104+ let versioned_package = "@google/gemini-cli@0.38.2" ;
105+ let unversioned_package = "cowsay" ;
106+
107+ // Simulate the logic from run_agent
108+ let versioned_arg = if versioned_package. contains ( '@' ) && versioned_package. matches ( '@' ) . count ( ) > 1 {
109+ versioned_package. to_string ( )
110+ } else {
111+ format ! ( "{}@latest" , versioned_package)
112+ } ;
113+
114+ let unversioned_arg = if unversioned_package. contains ( '@' ) && unversioned_package. matches ( '@' ) . count ( ) > 1 {
115+ unversioned_package. to_string ( )
116+ } else {
117+ format ! ( "{}@latest" , unversioned_package)
118+ } ;
119+
120+ assert_eq ! ( versioned_arg, "@google/gemini-cli@0.38.2" ) ;
121+ assert_eq ! ( unversioned_arg, "cowsay@latest" ) ;
98122}
0 commit comments