@@ -6,22 +6,13 @@ use crate::Error;
66pub async fn create_q_wrapper ( install_dir : & Path ) -> Result < ( ) , Error > {
77 let wrapper_path = install_dir. join ( "q" ) ;
88
9- // Check what exists and handle appropriately
10- if wrapper_path. exists ( ) {
11- let metadata = tokio:: fs:: symlink_metadata ( & wrapper_path) . await ?;
12-
13- if metadata. is_symlink ( ) {
14- // It's a symlink (likely from old installation) - safe to replace
15- tokio:: fs:: remove_file ( & wrapper_path) . await ?;
16- } else if is_our_wrapper ( & wrapper_path) . await ? {
17- // It's our wrapper from previous install - safe to replace
18- tokio:: fs:: remove_file ( & wrapper_path) . await ?;
19- } else {
20- // It's something else (assume old Q CLI) - safe to replace per our assumption
21- tokio:: fs:: remove_file ( & wrapper_path) . await ?;
22- }
9+ // Don't create wrapper if it never existed
10+ if !wrapper_path. exists ( ) {
11+ return Ok ( ( ) ) ;
2312 }
2413
14+ tokio:: fs:: remove_file ( & wrapper_path) . await ?;
15+
2516 // Create wrapper script content
2617 let wrapper_content = format ! (
2718 "#!/bin/sh\n \" {}/kiro-cli\" --show-legacy-warning \" $@\" \n " ,
@@ -47,11 +38,14 @@ pub async fn create_q_wrapper(install_dir: &Path) -> Result<(), Error> {
4738pub async fn create_qchat_wrapper ( install_dir : & Path ) -> Result < ( ) , Error > {
4839 let wrapper_path = install_dir. join ( "qchat" ) ;
4940
50- // Remove existing qchat command if it exists
51- if wrapper_path. exists ( ) {
52- tokio :: fs :: remove_file ( & wrapper_path ) . await ? ;
41+ // Don't create wrapper if it never existed
42+ if ! wrapper_path. exists ( ) {
43+ return Ok ( ( ) ) ;
5344 }
5445
46+ // Remove existing qchat command if it exists
47+ tokio:: fs:: remove_file ( & wrapper_path) . await ?;
48+
5549 // Create wrapper script content that calls q chat
5650 let wrapper_content = format ! ( "#!/bin/sh\n \" {}/q\" chat \" $@\" \n " , install_dir. display( ) ) ;
5751
@@ -69,13 +63,3 @@ pub async fn create_qchat_wrapper(install_dir: &Path) -> Result<(), Error> {
6963
7064 Ok ( ( ) )
7165}
72-
73- /// Check if the existing q command is our wrapper script
74- async fn is_our_wrapper ( path : & Path ) -> Result < bool , Error > {
75- if let Ok ( content) = tokio:: fs:: read_to_string ( path) . await {
76- // Check if it contains our signature
77- Ok ( content. contains ( "--show-legacy-warning" ) && content. contains ( "kiro-cli" ) )
78- } else {
79- Ok ( false )
80- }
81- }
0 commit comments