Skip to content

Commit b364a2f

Browse files
committed
Merge branch 'qv2' into qv2-merge
2 parents 9929156 + 9a29664 commit b364a2f

File tree

8 files changed

+54
-40
lines changed

8 files changed

+54
-40
lines changed

crates/fig_desktop/src/install.rs

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ use semver::Version;
1313
use tracing::{
1414
error,
1515
info,
16+
warn,
1617
};
1718

1819
#[allow(unused_imports)]
@@ -327,7 +328,18 @@ pub async fn initialize_fig_dir(env: &fig_os_shim::Env) -> anyhow::Result<()> {
327328

328329
for old_cli_binary_name in OLD_CLI_BINARY_NAMES {
329330
let old_cli_binary_path = local_bin.join(old_cli_binary_name);
330-
if old_cli_binary_path.is_symlink() {
331+
if old_cli_binary_name == &"q" {
332+
// Create wrapper script for q instead of symlink
333+
if let Err(err) = fig_util::wrapper::create_q_wrapper(&local_bin).await {
334+
warn!(%err, "Failed to create q wrapper script");
335+
}
336+
} else if old_cli_binary_name == &"qchat" {
337+
// Create wrapper script for qchat that calls q chat
338+
if let Err(err) = fig_util::wrapper::create_qchat_wrapper(&local_bin).await {
339+
warn!(%err, "Failed to create qchat wrapper script");
340+
}
341+
} else if old_cli_binary_path.is_symlink() {
342+
// Handle other legacy binaries (cw) with symlinks
331343
if let Err(err) = symlink(&q_cli_path, &old_cli_binary_path).await {
332344
warn!(%err, "Failed to symlink legacy CLI: {old_cli_binary_path:?}");
333345
}
@@ -660,6 +672,16 @@ async fn install_appimage_binaries(ctx: &Context) -> anyhow::Result<()> {
660672
}
661673
}
662674

675+
// Create q wrapper for backward compatibility
676+
if let Err(err) = fig_util::wrapper::create_q_wrapper(&home_local_bin_ctx(ctx)?).await {
677+
warn!(%err, "Failed to create q wrapper script");
678+
}
679+
680+
// Create qchat wrapper for backward compatibility
681+
if let Err(err) = fig_util::wrapper::create_qchat_wrapper(&home_local_bin_ctx(ctx)?).await {
682+
warn!(%err, "Failed to create qchat wrapper script");
683+
}
684+
663685
Ok(())
664686
}
665687

crates/fig_install/src/common.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ pub async fn uninstall(components: InstallComponents, ctx: Arc<Context>) -> Resu
7272
// let folders = [directories::home_local_bin()?, Path::new("/usr/local/bin").into()];
7373
let folders = [directories::home_local_bin()?];
7474

75-
let mut all_binary_names = vec![CLI_BINARY_NAME, CHAT_BINARY_NAME, PTY_BINARY_NAME, "q"];
75+
let mut all_binary_names = vec![CLI_BINARY_NAME, CHAT_BINARY_NAME, PTY_BINARY_NAME, "q", "qchat"];
7676
all_binary_names.extend(OLD_CLI_BINARY_NAMES);
7777
all_binary_names.extend(OLD_PTY_BINARY_NAMES);
7878

crates/fig_install/src/linux.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,6 @@ async fn replace_bins(bin_dir: &Path) -> Result<(), Error> {
111111
}
112112
}
113113

114-
// Create legacy q wrapper script after updating binaries
115-
if let Err(err) = fig_util::wrapper::create_q_wrapper(&local_bin).await {
116-
tracing::warn!("Failed to create q wrapper: {}", err);
117-
}
118-
119114
res
120115
}
121116

crates/fig_util/src/consts.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ pub const BACKUP_DIR_NAME: &str = ".amazon-q.dotfiles.bak";
3636

3737
// These are the old "CodeWhisperer" branding, used anywhere we will not update to Amazon Q
3838
pub const OLD_PRODUCT_NAME: &str = "CodeWhisperer";
39-
pub const OLD_CLI_BINARY_NAMES: &[&str] = &["cw"];
39+
pub const OLD_CLI_BINARY_NAMES: &[&str] = &["cw", "q", "qchat"];
4040
pub const OLD_PTY_BINARY_NAMES: &[&str] = &["cwterm"];
4141

4242
pub const GITHUB_REPO_NAME: &str = "aws/amazon-q-developer-cli";

crates/fig_util/src/wrapper.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,33 @@ pub async fn create_q_wrapper(install_dir: &Path) -> Result<(), Error> {
4343
Ok(())
4444
}
4545

46+
/// Create legacy qchat wrapper script for backward compatibility
47+
pub async fn create_qchat_wrapper(install_dir: &Path) -> Result<(), Error> {
48+
let wrapper_path = install_dir.join("qchat");
49+
50+
// Remove existing qchat command if it exists
51+
if wrapper_path.exists() {
52+
tokio::fs::remove_file(&wrapper_path).await?;
53+
}
54+
55+
// Create wrapper script content that calls q chat
56+
let wrapper_content = format!("#!/bin/sh\n\"{}/q\" chat \"$@\"\n", install_dir.display());
57+
58+
// Write wrapper script
59+
tokio::fs::write(&wrapper_path, wrapper_content).await?;
60+
61+
// Make executable
62+
#[cfg(unix)]
63+
{
64+
use std::os::unix::fs::PermissionsExt;
65+
let mut perms = tokio::fs::metadata(&wrapper_path).await?.permissions();
66+
perms.set_mode(0o755);
67+
tokio::fs::set_permissions(&wrapper_path, perms).await?;
68+
}
69+
70+
Ok(())
71+
}
72+
4673
/// Check if the existing q command is our wrapper script
4774
async fn is_our_wrapper(path: &Path) -> Result<bool, Error> {
4875
if let Ok(content) = tokio::fs::read_to_string(path).await {

crates/q_cli/src/cli/internal/mod.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -777,11 +777,6 @@ impl InternalSubcommand {
777777
tokio::time::sleep(Duration::from_millis(200)).await;
778778
}
779779

780-
// Create legacy q wrapper script for backward compatibility
781-
if let Err(err) = fig_util::wrapper::create_q_wrapper(&fig_util::directories::home_local_bin()?).await {
782-
tracing::warn!("Failed to create q wrapper: {}", err);
783-
}
784-
785780
launch_fig_desktop(LaunchArgs {
786781
wait_for_socket: false,
787782
open_dashboard: relaunch_dashboard,

crates/q_cli/src/cli/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ use crate::util::{
9090
is_logged_in_check,
9191
};
9292

93-
const LEGACY_WARNING: &str = "Warn: Q CLI is now Kiro CLI and should be invoked as kiro-cli rather than q";
93+
const LEGACY_WARNING: &str = "Warning! Q CLI is now Kiro CLI and should be invoked as kiro-cli rather than q";
9494

9595
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, ValueEnum)]
9696
pub enum OutputFormat {
@@ -304,7 +304,7 @@ impl Cli {
304304
pub async fn execute(self) -> Result<ExitCode> {
305305
// Show legacy warning if flag is set
306306
if self.show_legacy_warning {
307-
eprintln!("{}", LEGACY_WARNING);
307+
eprintln!("\x1b[33m{}\x1b[0m", LEGACY_WARNING);
308308
}
309309

310310
// Initialize our logger and keep around the guard so logging can perform as expected.

scripts/install.sh

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -318,23 +318,6 @@ create_symlink() {
318318
ln -s "$src" "$dst"
319319
}
320320

321-
# Create legacy q wrapper script
322-
create_q_wrapper() {
323-
local install_dir="$1"
324-
local wrapper_path="$install_dir/q"
325-
326-
# Remove existing q command if it exists
327-
rm -f "$wrapper_path"
328-
329-
# Create wrapper script
330-
cat > "$wrapper_path" << EOF
331-
#!/bin/sh
332-
"$install_dir/kiro-cli" --show-legacy-warning "\$@"
333-
EOF
334-
335-
chmod +x "$wrapper_path"
336-
}
337-
338321
# Install on macOS
339322
install_macos() {
340323
local dmg_path="$1"
@@ -475,14 +458,6 @@ main() {
475458
install_linux "$downloaded_file"
476459
fi
477460

478-
# Create legacy q wrapper script
479-
log "Creating legacy q wrapper..."
480-
if [[ "$os" == "macos" ]]; then
481-
create_q_wrapper "$HOME/.local/bin"
482-
else
483-
create_q_wrapper "$LINUX_INSTALL_DIR"
484-
fi
485-
486461
SUCCESS=true
487462

488463
echo

0 commit comments

Comments
 (0)