From 7f817c725baf501bc6648eedb8d0530365b6cd28 Mon Sep 17 00:00:00 2001 From: John Ajera Date: Tue, 1 Sep 2026 07:50:02 +1200 Subject: [PATCH] feat: add install_kiro.sh for Kiro IDE and optional CLI Automate the Fedora/Red Hat Kiro install flow from official metadata, with macOS zip support and optional CLI. Never launch the IDE GUI during install; verify via product.json and skip when already installed. --- README.md | 2 + docs/install_kiro.md | 141 +++++++++++++++++ scripts/install_kiro.sh | 329 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 472 insertions(+) create mode 100644 docs/install_kiro.md create mode 100755 scripts/install_kiro.sh diff --git a/README.md b/README.md index cc53070..c10f545 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,7 @@ Command-line interface tools/scripts - [install_hey.sh](docs/install_hey.md) - [install_k9s.sh](docs/install_k9s.md) - [install_kafka.sh](docs/install_kafka.md) +- [install_kiro.sh](docs/install_kiro.md) - [install_kustomize.sh](docs/install_kustomize.md) - [install_kubectl.sh](docs/install_kubectl.md) - [install_lm_studio.sh](docs/install_lm_studio.md) @@ -70,6 +71,7 @@ Refer to the respective files for detailed usage instructions: - **[install_hey.sh](docs/install_hey.md)**: Install or uninstall [hey](https://github.com/rakyll/hey) (HTTP load generator) from official prebuilt binaries or `go install` on arm64. - **[install_k9s.sh](docs/install_k9s.md)**: Install or uninstall k9s, a terminal UI for Kubernetes, on Linux and macOS. - **[install_kafka.sh](docs/install_kafka.md)**: Install or uninstall Apache Kafka on a Linux system. +- **[install_kiro.sh](docs/install_kiro.md)**: Install or uninstall the Kiro IDE (and optional CLI) on Linux x64 and macOS from official downloads. - **[install_kustomize.sh](docs/install_kustomize.md)**: Install or uninstall Kustomize (Kubernetes configuration management) on Linux and macOS from official GitHub releases. - **[install_kubectl.sh](docs/install_kubectl.md)**: Install or uninstall `kubectl` on a Linux system. - **[install_lm_studio.sh](docs/install_lm_studio.md)**: Install or uninstall LM Studio for running large language models locally with headless API server support. diff --git a/docs/install_kiro.md b/docs/install_kiro.md new file mode 100644 index 0000000..96ada91 --- /dev/null +++ b/docs/install_kiro.md @@ -0,0 +1,141 @@ +# install_kiro.sh + +This script installs or uninstalls [Kiro](https://kiro.dev), an AI-powered development environment from AWS. It follows the steps in [Installing Kiro on Fedora / Red Hat](https://dev.to/jajera/installing-kiro-on-fedora-red-hat-2i9g): download the official IDE tarball from Kiro metadata, install under `~/.local`, create a desktop entry, and optionally install the [Kiro CLI](https://kiro.dev/docs/cli/). + +## Usage + +```bash +./install_kiro.sh [install|uninstall|install-cli] +``` + +- **install** (default): Installs the Kiro IDE. +- **install-cli**: Installs only the Kiro CLI (`kiro-cli` / `q`) via the official installer. +- **uninstall**: Removes the local IDE install, desktop entry, and local CLI binaries if present. + +## Example Usage + +Install the IDE: + +```bash +./install_kiro.sh +``` + +Install IDE and CLI together: + +```bash +KIRO_WITH_CLI=1 ./install_kiro.sh install +``` + +Install CLI only: + +```bash +./install_kiro.sh install-cli +``` + +Uninstall: + +```bash +./install_kiro.sh uninstall +``` + +## Running Without Cloning + +```bash +bash <(curl -s https://raw.githubusercontent.com/jdevto/cli-tools/main/scripts/install_kiro.sh) install +``` + +Optional: `KIRO_WITH_CLI=1` to also install the CLI. + +## Verification + +```bash +test -x ~/.local/bin/kiro && echo "kiro binary OK" +test -f ~/.local/share/applications/kiro.desktop && echo "desktop entry OK" +``` + +Launch the IDE: + +```bash +kiro +``` + +Or open **Kiro** from your application menu (Linux desktop entry). + +Note: the IDE binary starts the GUI; it is not a CLI `--version` tool. For CLI tools, use `kiro-cli` after `install-cli`. + +CLI (if installed): + +```bash +kiro-cli --version +``` + +## Supported Operating Systems + +- **Linux** (x64) — Fedora / RHEL-family and Debian/Ubuntu-family; primary path matches the [Fedora/Red Hat guide](https://dev.to/jajera/installing-kiro-on-fedora-red-hat-2i9g) +- **macOS** — Intel (`x64`) and Apple Silicon (`arm64`) via official zip builds + +## Supported Architectures + +- **x64** (amd64) — Linux and macOS +- **arm64** — macOS only for the IDE (Linux arm64 IDE metadata is not published; CLI may still install) + +## Features + +- Resolves the latest IDE URL from official stable metadata (`prod.download.desktop.kiro.dev`) +- Linux: extracts to `~/.local/share/kiro`, symlinks `~/.local/bin/kiro`, creates a `.desktop` entry +- macOS: installs `Kiro.app` under `~/Applications` and symlinks a launcher into `~/.local/bin` +- Optional CLI via `https://cli.kiro.dev/install` +- Ensures `~/.local/bin` is on PATH in `~/.bashrc` / `~/.zshrc` when missing +- Idempotent: skips IDE install if already present (use `KIRO_FORCE=1` to reinstall) +- **Never launches the IDE GUI** during install; version comes from `product.json` +- Uninstall removes local IDE files and common CLI binaries + +## Optional environment variables + +| Variable | Default | Description | +| -------- | ------- | ----------- | +| `KIRO_WITH_CLI` | `0` | Set to `1` to install CLI during `install` | +| `KIRO_FORCE` | `0` | Set to `1` to reinstall even if IDE is already present | +| `KIRO_SHARE_DIR` | `~/.local/share/kiro` | Linux IDE install directory | +| `KIRO_BIN_DIR` | `~/.local/bin` | Directory for `kiro` / CLI symlinks | +| `KIRO_APPS_DIR` | `~/Applications` | macOS `.app` install directory | +| `KIRO_DESKTOP_DIR` | `~/.local/share/applications` | Linux desktop entry directory | + +## Prerequisites + +- **curl**, **jq** +- **tar** (Linux) or **unzip** (macOS) +- Package managers used only to install missing deps: `dnf` / `yum` / `apt-get` / `brew` + +## Uninstallation + +Removes: + +- `~/.local/share/kiro` (Linux IDE tree) +- `~/Applications/Kiro.app` (macOS, if used) +- `~/.local/bin/kiro`, and `kiro-cli` / `q` if present under `~/.local/bin` +- `~/.local/share/applications/kiro.desktop` + +Does not remove PATH lines added to shell profiles. + +## Troubleshooting + +1. **`kiro` not found after install** + Run `source ~/.bashrc` (or `~/.zshrc`) or open a new terminal. Confirm `~/.local/bin` is in `PATH`. + +2. **Desktop entry missing from the menu** + Run `update-desktop-database ~/.local/share/applications` or log out and back in. + +3. **jq / metadata errors** + Install `jq` (`sudo dnf install -y jq`). Metadata URL pattern: + `https://prod.download.desktop.kiro.dev/stable/metadata---stable.json` + +4. **Linux arm64 IDE** + Official IDE metadata for Linux arm64 is not available; use `install-cli` or an x64 host for the desktop IDE. + +## Additional Resources + +- [Kiro](https://kiro.dev) +- [Installation docs](https://kiro.dev/docs/getting-started/installation/) +- [Downloads](https://kiro.dev/downloads/) +- [Installing Kiro on Fedora / Red Hat](https://dev.to/jajera/installing-kiro-on-fedora-red-hat-2i9g) diff --git a/scripts/install_kiro.sh b/scripts/install_kiro.sh new file mode 100755 index 0000000..0a6a18b --- /dev/null +++ b/scripts/install_kiro.sh @@ -0,0 +1,329 @@ +#!/bin/bash + +set -e + +# Kiro IDE + optional CLI — based on: +# https://dev.to/jajera/installing-kiro-on-fedora-red-hat-2i9g +# Official downloads: https://kiro.dev/downloads/ +# CLI: https://cli.kiro.dev/install + +KIRO_WITH_CLI="${KIRO_WITH_CLI:-0}" +KIRO_SHARE_DIR="${KIRO_SHARE_DIR:-$HOME/.local/share/kiro}" +KIRO_BIN_DIR="${KIRO_BIN_DIR:-$HOME/.local/bin}" +KIRO_DESKTOP_DIR="${KIRO_DESKTOP_DIR:-$HOME/.local/share/applications}" +KIRO_APPS_DIR="${KIRO_APPS_DIR:-$HOME/Applications}" +TMP_DIR="" + +cleanup() { + if [ -n "$TMP_DIR" ] && [ -d "$TMP_DIR" ]; then + rm -rf "$TMP_DIR" + fi +} +trap cleanup EXIT + +detect_platform() { + if [[ "$OSTYPE" == "linux-gnu"* ]]; then + PLATFORM="linux" + elif [[ "$OSTYPE" == "darwin"* ]]; then + PLATFORM="darwin" + else + echo "Unsupported platform: $OSTYPE" + echo "Supported: Linux (x64) and macOS (Intel + Apple Silicon)." + exit 1 + fi +} + +detect_architecture() { + local arch + arch=$(uname -m) + case "$arch" in + x86_64) ARCH="x64" ;; + aarch64 | arm64) ARCH="arm64" ;; + *) + echo "Unsupported architecture: $arch" + exit 1 + ;; + esac +} + +ensure_local_bin_path() { + mkdir -p "$KIRO_BIN_DIR" + if [[ ":$PATH:" != *":$KIRO_BIN_DIR:"* ]]; then + export PATH="$KIRO_BIN_DIR:$PATH" + fi + for profile in "$HOME/.bashrc" "$HOME/.zshrc"; do + if [ -f "$profile" ] && ! grep -qF '.local/bin' "$profile" 2>/dev/null; then + echo 'export PATH="$HOME/.local/bin:$PATH"' >>"$profile" + fi + done +} + +install_dependencies() { + local missing=() + command -v curl &>/dev/null || missing+=("curl") + command -v jq &>/dev/null || missing+=("jq") + if [ "$PLATFORM" = "linux" ]; then + command -v tar &>/dev/null || missing+=("tar") + else + command -v unzip &>/dev/null || missing+=("unzip") + fi + + if [ ${#missing[@]} -eq 0 ]; then + return 0 + fi + + echo "Installing missing dependencies: ${missing[*]}" + if command -v dnf &>/dev/null; then + sudo dnf install -y "${missing[@]}" + elif command -v yum &>/dev/null; then + sudo yum install -y "${missing[@]}" + elif command -v apt-get &>/dev/null; then + sudo apt-get update + sudo apt-get install -y "${missing[@]}" + elif command -v brew &>/dev/null; then + brew install "${missing[@]}" + else + echo "Error: install ${missing[*]} manually and re-run." + exit 1 + fi +} + +metadata_url() { + echo "https://prod.download.desktop.kiro.dev/stable/metadata-${PLATFORM}-${ARCH}-stable.json" +} + +get_ide_download_url() { + local meta_url + meta_url=$(metadata_url) + local url + if [ "$PLATFORM" = "linux" ]; then + url=$(curl -fsSL "$meta_url" | jq -r '.releases[].updateTo.url | select(endswith(".tar.gz"))' | head -1) + else + url=$(curl -fsSL "$meta_url" | jq -r '.releases[].updateTo.url | select(endswith(".zip"))' | head -1) + fi + if [ -z "$url" ] || [ "$url" = "null" ]; then + echo "Error: Could not find Kiro IDE download URL for ${PLATFORM}/${ARCH}." + echo "Metadata: $meta_url" + exit 1 + fi + echo "$url" +} + +get_installed_ide_version() { + local product_json="$KIRO_SHARE_DIR/resources/app/product.json" + if [ -f "$product_json" ]; then + jq -r '.version // empty' "$product_json" 2>/dev/null || echo "unknown" + elif [ -x "$KIRO_SHARE_DIR/kiro" ] || [ -x "$KIRO_BIN_DIR/kiro" ]; then + echo "installed" + else + echo "none" + fi +} + +create_linux_desktop_entry() { + mkdir -p "$KIRO_DESKTOP_DIR" + local icon="$KIRO_SHARE_DIR/resources/app/resources/linux/code.png" + cat >"$KIRO_DESKTOP_DIR/kiro.desktop" </dev/null; then + update-desktop-database "$KIRO_DESKTOP_DIR" 2>/dev/null || true + fi +} + +install_ide_linux() { + if [ "$ARCH" != "x64" ]; then + echo "Error: Kiro IDE Linux builds are currently x64-only (detected: $ARCH)." + echo "You can still install the CLI with: $0 install-cli" + exit 1 + fi + + local url archive + url=$(get_ide_download_url) + archive="$TMP_DIR/kiro.tar.gz" + + echo "Downloading Kiro IDE from official metadata..." + echo "URL: $url" + curl -fsSL -o "$archive" "$url" + + echo "Installing to $KIRO_SHARE_DIR..." + rm -rf "$KIRO_SHARE_DIR" + mkdir -p "$KIRO_SHARE_DIR" + tar -xf "$archive" -C "$KIRO_SHARE_DIR" --strip-components=1 + + if [ ! -x "$KIRO_SHARE_DIR/kiro" ]; then + echo "Error: Expected binary not found at $KIRO_SHARE_DIR/kiro" + exit 1 + fi + + ensure_local_bin_path + ln -sf "$KIRO_SHARE_DIR/kiro" "$KIRO_BIN_DIR/kiro" + create_linux_desktop_entry +} + +install_ide_darwin() { + local url archive app_src + url=$(get_ide_download_url) + archive="$TMP_DIR/kiro.zip" + + echo "Downloading Kiro IDE from official metadata..." + echo "URL: $url" + curl -fsSL -o "$archive" "$url" + + echo "Extracting..." + unzip -qo "$archive" -d "$TMP_DIR/extract" + app_src=$(find "$TMP_DIR/extract" -maxdepth 2 -type d -name "Kiro.app" | head -1) + if [ -z "$app_src" ]; then + echo "Error: Kiro.app not found in download archive." + find "$TMP_DIR/extract" -maxdepth 3 -type d | head -20 + exit 1 + fi + + mkdir -p "$KIRO_APPS_DIR" + rm -rf "$KIRO_APPS_DIR/Kiro.app" + mv "$app_src" "$KIRO_APPS_DIR/Kiro.app" + + ensure_local_bin_path + local launcher="" + if [ -x "$KIRO_APPS_DIR/Kiro.app/Contents/Resources/app/bin/code" ]; then + launcher="$KIRO_APPS_DIR/Kiro.app/Contents/Resources/app/bin/code" + elif [ -x "$KIRO_APPS_DIR/Kiro.app/Contents/MacOS/Kiro" ]; then + launcher="$KIRO_APPS_DIR/Kiro.app/Contents/MacOS/Kiro" + elif [ -x "$KIRO_APPS_DIR/Kiro.app/Contents/MacOS/Electron" ]; then + launcher="$KIRO_APPS_DIR/Kiro.app/Contents/MacOS/Electron" + fi + if [ -n "$launcher" ]; then + ln -sf "$launcher" "$KIRO_BIN_DIR/kiro" + fi + + echo "Installed app: $KIRO_APPS_DIR/Kiro.app" +} + +install_ide() { + detect_platform + detect_architecture + install_dependencies + TMP_DIR=$(mktemp -d) + + local installed_version + installed_version=$(get_installed_ide_version) + if [ "$installed_version" != "none" ] && [ "${KIRO_FORCE:-0}" != "1" ] && [ "${KIRO_FORCE:-0}" != "true" ]; then + echo "Kiro IDE is already installed ($installed_version). Skipping." + echo "Set KIRO_FORCE=1 to reinstall. Launch with: kiro" + if [ "$KIRO_WITH_CLI" = "1" ] || [ "$KIRO_WITH_CLI" = "true" ]; then + install_cli + fi + return 0 + fi + + if [ "$installed_version" != "none" ]; then + echo "Reinstalling Kiro IDE (was $installed_version)..." + fi + + case "$PLATFORM" in + linux) install_ide_linux ;; + darwin) install_ide_darwin ;; + esac + + ensure_local_bin_path + if [ -x "$KIRO_BIN_DIR/kiro" ] || [ -x "$KIRO_SHARE_DIR/kiro" ]; then + echo "Kiro IDE installed successfully ($(get_installed_ide_version))." + echo "Launch with: kiro (or from the application menu)" + echo "Note: the installer never starts the IDE GUI." + else + echo "Kiro IDE files installed. Open a new shell or run: export PATH=\"$KIRO_BIN_DIR:\$PATH\"" + fi + + if [ "$KIRO_WITH_CLI" = "1" ] || [ "$KIRO_WITH_CLI" = "true" ]; then + install_cli + fi +} + +install_cli() { + echo "Installing Kiro CLI via official installer..." + curl -fsSL https://cli.kiro.dev/install | bash + ensure_local_bin_path + if command -v kiro-cli &>/dev/null; then + echo "Kiro CLI installed: $(command -v kiro-cli)" + timeout 5 kiro-cli --version 2>/dev/null || true + else + echo "CLI install finished. Ensure $KIRO_BIN_DIR is in PATH, then run: kiro-cli --version" + fi +} + +uninstall_kiro() { + echo "Uninstalling Kiro..." + + if [ -f "$KIRO_DESKTOP_DIR/kiro.desktop" ]; then + rm -f "$KIRO_DESKTOP_DIR/kiro.desktop" + echo "Removed desktop entry" + fi + + if [ -L "$KIRO_BIN_DIR/kiro" ] || [ -f "$KIRO_BIN_DIR/kiro" ]; then + rm -f "$KIRO_BIN_DIR/kiro" + echo "Removed $KIRO_BIN_DIR/kiro" + fi + + if [ -d "$KIRO_SHARE_DIR" ]; then + rm -rf "$KIRO_SHARE_DIR" + echo "Removed $KIRO_SHARE_DIR" + fi + + if [ -d "$KIRO_APPS_DIR/Kiro.app" ]; then + rm -rf "$KIRO_APPS_DIR/Kiro.app" + echo "Removed $KIRO_APPS_DIR/Kiro.app" + fi + + for cli_bin in kiro-cli q; do + if [ -L "$KIRO_BIN_DIR/$cli_bin" ] || [ -f "$KIRO_BIN_DIR/$cli_bin" ]; then + rm -f "$KIRO_BIN_DIR/$cli_bin" + echo "Removed $KIRO_BIN_DIR/$cli_bin" + fi + done + + echo "Kiro has been uninstalled." + echo "Note: shell PATH entries in ~/.bashrc / ~/.zshrc were left in place." +} + +usage() { + echo "Usage: $0 [install|uninstall|install-cli]" + echo "" + echo "Commands:" + echo " install Install Kiro IDE (default)" + echo " install-cli Install Kiro CLI only (kiro-cli / q)" + echo " uninstall Remove Kiro IDE (and local CLI binaries if present)" + echo "" + echo "Optional environment variables:" + echo " KIRO_WITH_CLI=1 Also install CLI during 'install'" + echo " KIRO_FORCE=1 Reinstall IDE even if already present" + echo " KIRO_SHARE_DIR IDE install dir (default: ~/.local/share/kiro)" + echo " KIRO_BIN_DIR Symlink dir (default: ~/.local/bin)" + echo " KIRO_APPS_DIR macOS .app dir (default: ~/Applications)" + echo "" + echo "Examples:" + echo " $0 install" + echo " KIRO_WITH_CLI=1 $0 install" + echo " KIRO_FORCE=1 $0 install" + echo " $0 install-cli" + echo " $0 uninstall" + exit 1 +} + +case "${1:-install}" in + install) install_ide ;; + install-cli) install_cli ;; + uninstall) uninstall_kiro ;; + *) usage ;; +esac + +if [ "${1:-install}" != "uninstall" ]; then + echo "" + echo "Done. See https://kiro.dev/docs/getting-started/installation/" + echo "Guide this script follows: https://dev.to/jajera/installing-kiro-on-fedora-red-hat-2i9g" +fi