Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 14 additions & 12 deletions build-scripts/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
from importlib import import_module
from const import (
APP_NAME,
CHAT_BINARY_BRANCH,
CHAT_BINARY_NAME,
CHAT_PACKAGE_NAME,
CLI_BINARY_NAME,
Expand All @@ -51,6 +52,7 @@
MACOS_BUNDLE_ID,
PTY_BINARY_NAME,
PTY_PACKAGE_NAME,
TAURI_PRODUCT_NAME,
URL_SCHEMA,
)

Expand Down Expand Up @@ -179,7 +181,7 @@ def fetch_chat_bin(chat_build_bucket_name: str | None, chat_download_role_arn: s
warn("missing required chat arguments, creating dummy binary")
dummy_dir = BUILD_DIR / "dummy_chat"
dummy_dir.mkdir(exist_ok=True)
dummy_path = dummy_dir / f"qchat-{get_target_triple()}"
dummy_path = dummy_dir / f"{CHAT_BINARY_NAME}-{get_target_triple()}"
dummy_path.write_text("#!/usr/bin/env sh\n\necho dummy chat binary\n")
set_executable(dummy_path)
return dummy_path
Expand All @@ -205,21 +207,21 @@ def fetch_chat_bin(chat_build_bucket_name: str | None, chat_download_role_arn: s
)

# The path to the download should be:
# BUILD_BUCKET/prod/latest/{target}/qchat.zip
# BUILD_BUCKET/{CHAT_BINARY_BRANCH}/latest/{target}/{CHAT_BINARY_NAME}.zip
Comment on lines -208 to +210

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for doing the branch as well !!

target = get_target_triple()
chat_bucket_path = f"prod/latest/{target}/qchat.zip"
chat_bucket_path = f"{CHAT_BINARY_BRANCH}/latest/{target}/{CHAT_BINARY_NAME}.zip"
chat_dl_dir = BUILD_DIR / "chat_download"
chat_dl_dir.mkdir(exist_ok=True)
chat_dl_path = chat_dl_dir / "qchat.zip"
info(f"Downloading qchat zip from bucket: {chat_bucket_path} and path: {chat_bucket_path}")
chat_dl_path = chat_dl_dir / f"{CHAT_BINARY_NAME}.zip"
info(f"Downloading {CHAT_BINARY_NAME} zip from bucket: {chat_bucket_path} and path: {chat_bucket_path}")
s3.download_file(chat_build_bucket_name, chat_bucket_path, chat_dl_path)

# unzip and return the path to the contained binary
run_cmd(["unzip", "-o", chat_dl_path, "-d", chat_dl_dir])

# Append target triple, as expected by tauri cli.
chat_path = chat_dl_dir / f"qchat-{target}"
(chat_dl_dir / "qchat").rename(chat_path)
chat_path = chat_dl_dir / f"{CHAT_BINARY_NAME}-{target}"
(chat_dl_dir / CHAT_BINARY_NAME).rename(chat_path)
return chat_path


Expand Down Expand Up @@ -341,7 +343,7 @@ def build_macos_desktop_app(
manifest_path.unlink(missing_ok=True)
tauri_config_path.unlink(missing_ok=True)

target_bundle = pathlib.Path(f"target/{target}/release/bundle/macos/q_desktop.app")
target_bundle = pathlib.Path(f"target/{target}/release/bundle/macos/{TAURI_PRODUCT_NAME}.app")
app_path = BUILD_DIR / f"{APP_NAME}.app"
shutil.rmtree(app_path, ignore_errors=True)
shutil.copytree(target_bundle, app_path)
Expand Down Expand Up @@ -466,9 +468,9 @@ def build_linux_minimal(cli_path: pathlib.Path, pty_path: pathlib.Path, chat_pat
Creates tar.gz, tar.xz, tar.zst, and zip archives under `BUILD_DIR`.

Each archive has the following structure:
- archive/bin/q
- archive/bin/qterm
- archive/bin/qchat
- archive/bin/{cli_binary}
- archive/bin/{pty_binary}
- archive/bin/{chat_binary}
- archive/install.sh
- archive/README
- archive/BUILD-INFO
Expand Down Expand Up @@ -879,7 +881,7 @@ def build(
else:
signing_data = None

cargo_features: Mapping[str, Sequence[str]] = {"q_cli": ["wayland"]}
cargo_features: Mapping[str, Sequence[str]] = {CLI_PACKAGE_NAME: ["wayland"]}

match stage_name:
case "prod" | None:
Expand Down
2 changes: 2 additions & 0 deletions build-scripts/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@

APP_NAME = "Amazon Q"
CLI_BINARY_NAME = "q"
CLI_BINARY_NAME_MINIMAL = "q-minimal"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I didn't find this variable being used anywhere, Follow up CRs ?

CHAT_BINARY_NAME = "qchat"
PTY_BINARY_NAME = "qterm"
DESKTOP_BINARY_NAME = "q-desktop"
URL_SCHEMA = "q"
TAURI_PRODUCT_NAME = "q_desktop"
LINUX_PACKAGE_NAME = "amazon-q"
CHAT_BINARY_BRANCH = "prod"

# macos specific
MACOS_BUNDLE_ID = "com.amazon.codewhisperer"
Expand Down
16 changes: 8 additions & 8 deletions build-scripts/manifest.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from dataclasses import dataclass
from enum import Enum

from const import APPLE_TEAM_ID
from const import APPLE_TEAM_ID, APP_NAME, CLI_BINARY_NAME, PTY_BINARY_NAME, CHAT_BINARY_NAME


class CdSigningType(Enum):
Expand Down Expand Up @@ -52,21 +52,21 @@ def manifest(

def app_manifest():
return manifest(
name="Amazon Q.app",
name=f"{APP_NAME}.app",
identifier="com.amazon.codewhisperer",
entitlements=True,
embedded_requirements=[
EmbeddedRequirement(
path="Contents/MacOS/q",
identifier="com.amazon.q",
path=f"Contents/MacOS/{CLI_BINARY_NAME}",
identifier=f"com.amazon.{CLI_BINARY_NAME}",
),
EmbeddedRequirement(
path="Contents/MacOS/qterm",
identifier="com.amazon.qterm",
path=f"Contents/MacOS/{PTY_BINARY_NAME}",
identifier=f"com.amazon.{PTY_BINARY_NAME}",
),
EmbeddedRequirement(
path="Contents/MacOS/qchat",
identifier="com.amazon.qchat",
path=f"Contents/MacOS/{CHAT_BINARY_NAME}",
identifier=f"com.amazon.{CHAT_BINARY_NAME}",
),
],
)
Expand Down
6 changes: 3 additions & 3 deletions build-scripts/qchatbuild.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ def cd_build_signed_package(exe_path: pathlib.Path):
```
package
├─ EXECUTABLES_TO_SIGN
| ├─ qchat
| ├─ {chat_binary}
```
"""
# Trying a different format without manifest.yaml and placing EXECUTABLES_TO_SIGN
Expand Down Expand Up @@ -376,7 +376,7 @@ def sign_and_notarize(signing_data: CdSigningData, chat_path: pathlib.Path) -> p

def build_macos(chat_path: pathlib.Path, signing_data: CdSigningData | None):
"""
Creates a qchat.zip under the build directory.
Creates a chat binary zip under the build directory.
"""
chat_dst = BUILD_DIR / CHAT_BINARY_NAME
chat_dst.unlink(missing_ok=True)
Expand Down Expand Up @@ -495,7 +495,7 @@ def build_linux(chat_path: pathlib.Path, signer: GpgSigner | None):
Creates tar.gz, tar.xz, tar.zst, and zip archives under `BUILD_DIR`.

Each archive has the following structure:
- archive/qchat
- archive/{chat_binary}
"""
archive_name = CHAT_BINARY_NAME

Expand Down
2 changes: 1 addition & 1 deletion build-scripts/qchatmain.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def __call__(self, parser, namespace, values, option_string=None):

parser = argparse.ArgumentParser(
prog="build",
description="Builds the qchat binary",
description="Builds the chat binary",
)
subparsers = parser.add_subparsers(help="sub-command help", dest="subparser", required=True)

Expand Down
21 changes: 12 additions & 9 deletions bundle/linux/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ set -o errexit
set -o nounset

SCRIPT_DIR="$(dirname "$(readlink -f "$0")")"
CLI_BINARY_NAME="q"
CHAT_BINARY_NAME="qchat"
PTY_BINARY_NAME="qterm"

log_error() {
printf '\e[31m[ERROR]\e[0m %s\n' "$1" >&2
Expand Down Expand Up @@ -136,22 +139,22 @@ if is_target_triple_gnu && ! check_glibc_version; then
fi

if [ -n "${Q_INSTALL_GLOBAL:-}" ]; then
install -m 755 "$SCRIPT_DIR/bin/q" /usr/local/bin/
install -m 755 "$SCRIPT_DIR/bin/qchat" /usr/local/bin/
install -m 755 "$SCRIPT_DIR/bin/qterm" /usr/local/bin/
install -m 755 "$SCRIPT_DIR/bin/$CLI_BINARY_NAME" /usr/local/bin/
install -m 755 "$SCRIPT_DIR/bin/$CHAT_BINARY_NAME" /usr/local/bin/
install -m 755 "$SCRIPT_DIR/bin/$PTY_BINARY_NAME" /usr/local/bin/

if [ -z "${Q_SKIP_SETUP:-}" ]; then
/usr/local/bin/q integrations install dotfiles
/usr/local/bin/q setup --global "$@"
/usr/local/bin/$CLI_BINARY_NAME integrations install dotfiles
/usr/local/bin/$CLI_BINARY_NAME setup --global "$@"
fi
else
mkdir -p "$HOME/.local/bin"

install -m 755 "$SCRIPT_DIR/bin/q" "$HOME/.local/bin/"
install -m 755 "$SCRIPT_DIR/bin/qchat" "$HOME/.local/bin/"
install -m 755 "$SCRIPT_DIR/bin/qterm" "$HOME/.local/bin/"
install -m 755 "$SCRIPT_DIR/bin/$CLI_BINARY_NAME" "$HOME/.local/bin/"
install -m 755 "$SCRIPT_DIR/bin/$CHAT_BINARY_NAME" "$HOME/.local/bin/"
install -m 755 "$SCRIPT_DIR/bin/$PTY_BINARY_NAME" "$HOME/.local/bin/"

if [ -z "${Q_SKIP_SETUP:-}" ]; then
"$HOME/.local/bin/q" setup "$@"
"$HOME/.local/bin/$CLI_BINARY_NAME" setup "$@"
fi
fi
1 change: 1 addition & 0 deletions crates/chat-cli/src/cli/chat/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ impl ContextManager {
///
/// # Returns
/// A Result containing a vector of profile names, with "default" always first
#[cfg_attr(target_os = "windows", allow(dead_code))]
pub fn list_profiles_blocking(&self, os: &Os) -> Result<Vec<String>> {
let _ = self;

Expand Down
7 changes: 6 additions & 1 deletion crates/chat-cli/src/cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ use crate::logging::{
use crate::os::Os;
use crate::util::directories::logs_dir;
use crate::util::{
CHAT_BINARY_NAME,
CLI_BINARY_NAME,
GOV_REGIONS,
};
Expand Down Expand Up @@ -216,7 +217,11 @@ impl Cli {
},
log_to_stdout: std::env::var_os("Q_LOG_STDOUT").is_some() || self.verbose > 0,
log_file_path: match subcommand {
RootSubcommand::Chat { .. } => Some(logs_dir().expect("home dir must be set").join("qchat.log")),
RootSubcommand::Chat { .. } => Some(
logs_dir()
.expect("home dir must be set")
.join(format!("{CHAT_BINARY_NAME}.log")),
),
_ => None,
},
delete_old_log_file: false,
Expand Down
3 changes: 2 additions & 1 deletion crates/chat-cli/src/logging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use tracing_subscriber::{
fmt,
};

use crate::util::consts::CHAT_BINARY_NAME;
use crate::util::env_var::Q_LOG_LEVEL;

const MAX_FILE_SIZE: u64 = 10 * 1024 * 1024;
Expand Down Expand Up @@ -76,7 +77,7 @@ pub fn initialize_logging<T: AsRef<Path>>(args: LogArgs<T>) -> Result<LogGuard,

// Make the log path parent directory if it doesn't exist.
if let Some(parent) = log_path.parent() {
if log_path.ends_with("qchat.log") {
if log_path.ends_with(format!("{CHAT_BINARY_NAME}.log")) {
mcp_path = Some(parent.to_path_buf());
}
std::fs::create_dir_all(parent)?;
Expand Down
2 changes: 2 additions & 0 deletions crates/fig_integrations/src/shell/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ impl ShellExt for Shell {
include_str!("scripts/bash-preexec.sh"),
"}\n",
"__fig_source_bash_preexec\n",
"# shellcheck disable=SC2329\n",
"function __bp_adjust_histcontrol() { :; }\n",
include_str!("scripts/pre.sh")
)
Expand All @@ -208,6 +209,7 @@ impl ShellExt for Shell {
include_str!("scripts/bash-preexec.sh"),
"}\n",
"__fig_source_bash_preexec\n",
"# shellcheck disable=SC2329\n",
"function __bp_adjust_histcontrol() { :; }\n",
include_str!("scripts/post.bash")
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ __bp_require_not_readonly() {
# Remove ignorespace and or replace ignoreboth from HISTCONTROL
# so we can accurately invoke preexec with a command from our
# history even if it starts with a space.
# shellcheck disable=SC2317
# shellcheck disable=SC2317,SC2329
__bp_adjust_histcontrol() {
local histcontrol
histcontrol="${HISTCONTROL:-}"
Expand Down
3 changes: 2 additions & 1 deletion crates/fig_log/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use std::fs::File;
use std::path::Path;
use std::sync::Mutex;

use fig_util::CHAT_BINARY_NAME;
use fig_util::env_var::Q_LOG_LEVEL;
use thiserror::Error;
use tracing::info;
Expand Down Expand Up @@ -75,7 +76,7 @@ pub fn initialize_logging<T: AsRef<Path>>(args: LogArgs<T>) -> Result<LogGuard,

// Make the log path parent directory if it doesn't exist.
if let Some(parent) = log_path.parent() {
if log_path.ends_with("qchat.log") {
if log_path.ends_with(format!("{CHAT_BINARY_NAME}.log")) {
mcp_path = Some(parent.to_path_buf());
}
std::fs::create_dir_all(parent)?;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
source: q_cli/tests/init.rs
source: crates/q_cli/tests/init.rs
expression: init
---
Q_SHELL="/bin/zsh"
Expand Down Expand Up @@ -94,7 +94,7 @@ __bp_require_not_readonly() {
# Remove ignorespace and or replace ignoreboth from HISTCONTROL
# so we can accurately invoke preexec with a command from our
# history even if it starts with a space.
# shellcheck disable=SC2317
# shellcheck disable=SC2317,SC2329
__bp_adjust_histcontrol() {
local histcontrol
histcontrol="${HISTCONTROL:-}"
Expand Down Expand Up @@ -387,6 +387,7 @@ if [[ -z "${__bp_delay_install:-}" ]]; then
fi;
}
__fig_source_bash_preexec
# shellcheck disable=SC2329
function __bp_adjust_histcontrol() { :; }
if [[ -n "${BASH:-}" ]]; then

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
source: q_cli/tests/init.rs
source: crates/q_cli/tests/init.rs
expression: init
---
Q_SHELL="/bin/zsh"
Expand Down Expand Up @@ -94,7 +94,7 @@ __bp_require_not_readonly() {
# Remove ignorespace and or replace ignoreboth from HISTCONTROL
# so we can accurately invoke preexec with a command from our
# history even if it starts with a space.
# shellcheck disable=SC2317
# shellcheck disable=SC2317,SC2329
__bp_adjust_histcontrol() {
local histcontrol
histcontrol="${HISTCONTROL:-}"
Expand Down Expand Up @@ -387,6 +387,7 @@ if [[ -z "${__bp_delay_install:-}" ]]; then
fi;
}
__fig_source_bash_preexec
# shellcheck disable=SC2329
function __bp_adjust_histcontrol() { :; }
if [[ -n "${BASH:-}" ]]; then

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
source: q_cli/tests/init.rs
source: crates/q_cli/tests/init.rs
expression: init
---
Q_SHELL="/bin/zsh"
Expand Down Expand Up @@ -95,7 +95,7 @@ __bp_require_not_readonly() {
# Remove ignorespace and or replace ignoreboth from HISTCONTROL
# so we can accurately invoke preexec with a command from our
# history even if it starts with a space.
# shellcheck disable=SC2317
# shellcheck disable=SC2317,SC2329
__bp_adjust_histcontrol() {
local histcontrol
histcontrol="${HISTCONTROL:-}"
Expand Down Expand Up @@ -388,6 +388,7 @@ if [[ -z "${__bp_delay_install:-}" ]]; then
fi;
}
__fig_source_bash_preexec
# shellcheck disable=SC2329
function __bp_adjust_histcontrol() { :; }
#!/usr/bin/env bash

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
source: q_cli/tests/init.rs
source: crates/q_cli/tests/init.rs
expression: init
---
Q_SHELL="/bin/zsh"
Expand Down Expand Up @@ -95,7 +95,7 @@ __bp_require_not_readonly() {
# Remove ignorespace and or replace ignoreboth from HISTCONTROL
# so we can accurately invoke preexec with a command from our
# history even if it starts with a space.
# shellcheck disable=SC2317
# shellcheck disable=SC2317,SC2329
__bp_adjust_histcontrol() {
local histcontrol
histcontrol="${HISTCONTROL:-}"
Expand Down Expand Up @@ -388,6 +388,7 @@ if [[ -z "${__bp_delay_install:-}" ]]; then
fi;
}
__fig_source_bash_preexec
# shellcheck disable=SC2329
function __bp_adjust_histcontrol() { :; }
#!/usr/bin/env bash

Expand Down
Loading
Loading