Skip to content

feat: Make standalone CLI #1496

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 6, 2025
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
1,545 changes: 933 additions & 612 deletions Cargo.lock

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ objc2-input-method-kit = "0.2.2"
parking_lot = "0.12.3"
percent-encoding = "2.2.0"
portable-pty = "0.8.1"
q_chat = { path = "crates/q_chat" }
r2d2 = "0.8.10"
r2d2_sqlite = "0.25.0"
rand = "0.9.0"
Expand Down
27 changes: 25 additions & 2 deletions build-scripts/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
from importlib import import_module
from const import (
APP_NAME,
CHAT_BINARY_NAME,
CHAT_PACKAGE_NAME,
CLI_BINARY_NAME,
CLI_PACKAGE_NAME,
DESKTOP_BINARY_NAME,
Expand Down Expand Up @@ -208,12 +210,13 @@ def build_macos_ime(
return input_method_app


def macos_tauri_config(cli_path: pathlib.Path, pty_path: pathlib.Path, target: str) -> str:
def macos_tauri_config(cli_path: pathlib.Path, chat_path: pathlib.Path, pty_path: pathlib.Path, target: str) -> str:
config = {
"tauri": {
"bundle": {
"externalBin": [
str(cli_path).removesuffix(f"-{target}"),
str(chat_path).removesuffix(f"-{target}"),
str(pty_path).removesuffix(f"-{target}"),
],
"resources": ["manifest.json"],
Expand All @@ -227,6 +230,7 @@ def build_macos_desktop_app(
release: bool,
pty_path: pathlib.Path,
cli_path: pathlib.Path,
chat_path: pathlib.Path,
npm_packages: NpmBuildOutput,
is_prod: bool,
signing_data: CdSigningData | None,
Expand All @@ -244,7 +248,7 @@ def build_macos_desktop_app(

info("Building tauri config")
tauri_config_path = pathlib.Path(DESKTOP_PACKAGE_PATH) / "build-config.json"
tauri_config_path.write_text(macos_tauri_config(cli_path=cli_path, pty_path=pty_path, target=target))
tauri_config_path.write_text(macos_tauri_config(cli_path=cli_path, chat_path=chat_path, pty_path=pty_path, target=target))

info("Building", DESKTOP_PACKAGE_NAME)

Expand Down Expand Up @@ -467,6 +471,7 @@ def build_linux_minimal(cli_path: pathlib.Path, pty_path: pathlib.Path):
def linux_tauri_config(
cli_path: pathlib.Path,
pty_path: pathlib.Path,
chat_path: pathlib.Path,
dashboard_path: pathlib.Path,
autocomplete_path: pathlib.Path,
vscode_path: pathlib.Path,
Expand All @@ -483,6 +488,7 @@ def linux_tauri_config(
"externalBin": [
str(cli_path).removesuffix(f"-{target}"),
str(pty_path).removesuffix(f"-{target}"),
str(chat_path).removesuffix(f"-{target}"),
],
"targets": ["appimage"],
"icon": ["icons/128x128.png"],
Expand Down Expand Up @@ -535,6 +541,7 @@ def make_linux_bundle_metadata(packaged_as: Package) -> pathlib.Path:
class LinuxDebResources:
cli_path: pathlib.Path
pty_path: pathlib.Path
chat_path: pathlib.Path
desktop_path: pathlib.Path
themes_path: pathlib.Path
legacy_extension_dir_path: pathlib.Path
Expand Down Expand Up @@ -573,6 +580,7 @@ def build_linux_deb(
bin_path.mkdir(parents=True)
shutil.copy(resources.cli_path, bin_path / CLI_BINARY_NAME)
shutil.copy(resources.pty_path, bin_path / PTY_BINARY_NAME)
shutil.copy(resources.chat_path, bin_path / CHAT_BINARY_NAME)
shutil.copy(resources.desktop_path, bin_path / DESKTOP_BINARY_NAME)

info("Copying /usr/share resources")
Expand Down Expand Up @@ -629,6 +637,7 @@ def build_linux_full(
release: bool,
cli_path: pathlib.Path,
pty_path: pathlib.Path,
chat_path: pathlib.Path,
npm_packages: NpmBuildOutput,
features: Mapping[str, Sequence[str]] | None = None,
):
Expand Down Expand Up @@ -668,6 +677,7 @@ def copy_extension(extension_uuid, extension_dir_name):
linux_tauri_config(
cli_path=cli_path,
pty_path=pty_path,
chat_path=chat_path,
dashboard_path=npm_packages.dashboard_path,
autocomplete_path=npm_packages.autocomplete_path,
vscode_path=npm_packages.vscode_path,
Expand Down Expand Up @@ -703,6 +713,7 @@ def copy_extension(extension_uuid, extension_dir_name):
deb_resources = LinuxDebResources(
cli_path=cli_path,
pty_path=pty_path,
chat_path=chat_path,
desktop_path=desktop_path,
themes_path=themes_path,
legacy_extension_dir_path=legacy_extension_dir_path,
Expand Down Expand Up @@ -846,6 +857,16 @@ def build(
targets=targets,
)

info("Building", CHAT_PACKAGE_NAME)
chat_path = build_cargo_bin(
variant=variant,
release=release,
package=CHAT_PACKAGE_NAME,
output_name=CHAT_BINARY_NAME,
features=cargo_features,
targets=targets,
)

info("Building", PTY_PACKAGE_NAME)
pty_path = build_cargo_bin(
variant=variant,
Expand All @@ -864,6 +885,7 @@ def build(
build_paths = build_macos_desktop_app(
release=release,
cli_path=cli_path,
chat_path=chat_path,
pty_path=pty_path,
npm_packages=npm_packages,
signing_data=signing_data,
Expand All @@ -889,6 +911,7 @@ def build(
release=release,
cli_path=cli_path,
pty_path=pty_path,
chat_path=chat_path,
npm_packages=npm_packages,
features=cargo_features,
)
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,6 +3,7 @@

APP_NAME = "Amazon Q"
CLI_BINARY_NAME = "q"
CHAT_BINARY_NAME = "qchat"
PTY_BINARY_NAME = "qterm"
DESKTOP_BINARY_NAME = "q-desktop"
URL_SCHEMA = "q"
Expand All @@ -20,6 +21,7 @@

# cargo packages
CLI_PACKAGE_NAME = "q_cli"
CHAT_PACKAGE_NAME = "chat_cli"
PTY_PACKAGE_NAME = "figterm"
DESKTOP_PACKAGE_NAME = "fig_desktop"
DESKTOP_FUZZ_PACKAGE_NAME = "fig_desktop-fuzz"
Expand Down
2 changes: 2 additions & 0 deletions bundle/linux/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ 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/

/usr/local/bin/q integrations install dotfiles
Expand All @@ -145,6 +146,7 @@ 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/"

"$HOME/.local/bin/q" setup "$@"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,10 @@

[package]
edition = "2021"
name = "amzn-toolkit-telemetry"
name = "amzn-toolkit-telemetry-client"
version = "1.0.0"
authors = ["Grant Gurvis <grangurv@amazon.com>"]
exclude = [
"/build",
"/Config",
"/build-tools/",
]
exclude = ["/build", "/Config", "/build-tools/"]
publish = ["brazil"]
description = "Rust client bindings for the toolkit-telemetry service"

Expand Down Expand Up @@ -53,10 +49,7 @@ features = ["client"]

[dependencies.aws-smithy-runtime-api]
version = "1.1.3"
features = [
"client",
"http-02x",
]
features = ["client", "http-02x"]

[dependencies.aws-smithy-types]
version = "1.1.3"
Expand All @@ -79,16 +72,7 @@ features = ["test-util"]

[features]
behavior-version-latest = []
default = [
"rustls",
"rt-tokio",
]
rt-tokio = [
"aws-smithy-async/rt-tokio",
"aws-smithy-types/rt-tokio",
]
default = ["rustls", "rt-tokio"]
rt-tokio = ["aws-smithy-async/rt-tokio", "aws-smithy-types/rt-tokio"]
rustls = ["aws-smithy-runtime/tls-rustls"]
test-util = [
"aws-credential-types/test-util",
"aws-smithy-runtime/test-util",
]
test-util = ["aws-credential-types/test-util", "aws-smithy-runtime/test-util"]
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ impl Client {
/// operation call. For example, this can be used to add an additional HTTP header:
///
/// ```ignore
/// # async fn wrapper() -> ::std::result::Result<(), amzn_toolkit_telemetry::Error> {
/// # let client: amzn_toolkit_telemetry::Client = unimplemented!();
/// # async fn wrapper() -> ::std::result::Result<(), amzn_toolkit_telemetry_client::Error> {
/// # let client: amzn_toolkit_telemetry_client::Client = unimplemented!();
/// use ::http::header::{HeaderName, HeaderValue};
///
/// let result = client.post_error_report()
Expand Down
Loading
Loading