#!/bin/sh # Keelmark installer for macOS and Linux. # curl -fsSL https://keelmark.dev/install.sh | sh # Options (environment variables): # KEELMARK_VERSION=0.1.0 install a specific release instead of the latest # KEELMARK_INSTALL_DIR=~/bin where the binary goes (default: ~/.keelmark/bin) # KEELMARK_NO_MODIFY_PATH=1 don't add the install directory to your shell profile # Downloads the binary for this machine from GitHub Releases, checks its SHA-256, and # installs it. The only other change is one PATH line in your shell profile (zsh, bash or # fish), added once, and only if the directory isn't on your PATH already. set -eu REPO="DustinDoan315/keelmark-cli" BASE="${KEELMARK_DOWNLOAD_BASE:-https://github.com/$REPO/releases}" INSTALL_DIR="${KEELMARK_INSTALL_DIR:-$HOME/.keelmark/bin}" say() { printf '%s\n' "$*"; } fail() { printf 'keelmark install: %s\n' "$*" >&2; exit 1; } case "$(uname -s)" in Darwin) os=darwin ;; Linux) os=linux ;; *) fail "unsupported system $(uname -s). On Windows run: irm https://keelmark.dev/install.ps1 | iex" ;; esac case "$(uname -m)" in arm64 | aarch64) arch=arm64 ;; x86_64 | amd64) arch=x64 ;; *) fail "unsupported CPU $(uname -m)" ;; esac # Rosetta: an Intel shell on Apple silicon still gets the native build. if [ "$os" = darwin ] && [ "$arch" = x64 ] && [ "$(sysctl -n sysctl.proc_translated 2>/dev/null || echo 0)" = 1 ]; then arch=arm64 fi asset="keelmark-$os-$arch.tar.gz" if [ -n "${KEELMARK_VERSION:-}" ]; then url="$BASE/download/v${KEELMARK_VERSION#v}" else url="$BASE/latest/download" fi command -v curl >/dev/null 2>&1 || fail "curl is required" tmp="$(mktemp -d)" trap 'rm -rf "$tmp"' EXIT INT TERM say "Downloading Keelmark for $os-$arch..." curl -fsSL "$url/$asset" -o "$tmp/$asset" || fail "download failed: $url/$asset" curl -fsSL "$url/SHA256SUMS" -o "$tmp/SHA256SUMS" || fail "could not download checksums" expected="$(grep " $asset\$" "$tmp/SHA256SUMS" | cut -d' ' -f1)" [ -n "$expected" ] || fail "no checksum listed for $asset" if command -v sha256sum >/dev/null 2>&1; then actual="$(sha256sum "$tmp/$asset" | cut -d' ' -f1)" else actual="$(shasum -a 256 "$tmp/$asset" | cut -d' ' -f1)" fi [ "$expected" = "$actual" ] || fail "checksum mismatch for $asset; not installing" mkdir -p "$INSTALL_DIR" tar -xzf "$tmp/$asset" -C "$tmp" mv "$tmp/keelmark" "$INSTALL_DIR/keelmark" chmod 755 "$INSTALL_DIR/keelmark" say "Installed $("$INSTALL_DIR/keelmark" --version 2>/dev/null || echo keelmark) to $INSTALL_DIR/keelmark" run="keelmark" on_path() { case ":$PATH:" in *":$1:"*) return 0 ;; esac; return 1; } # Works right away when a folder you already have on PATH can hold a link (no new terminal needed). linked="" if ! on_path "$INSTALL_DIR"; then for dir in "$HOME/.local/bin" "$HOME/bin"; do if on_path "$dir" && [ -d "$dir" ] && [ -w "$dir" ]; then ln -sf "$INSTALL_DIR/keelmark" "$dir/keelmark" && linked="$dir" && break fi done fi if [ -n "$linked" ]; then say "Linked it into $linked, which is already on your PATH: \`keelmark\` works now." elif ! on_path "$INSTALL_DIR"; then run="$INSTALL_DIR/keelmark" case "${SHELL:-}" in */zsh) profile="$HOME/.zshrc"; line="export PATH=\"$INSTALL_DIR:\$PATH\"" ;; */bash) profile="$HOME/.bashrc"; line="export PATH=\"$INSTALL_DIR:\$PATH\"" ;; */fish) profile="$HOME/.config/fish/config.fish"; line="fish_add_path $INSTALL_DIR" ;; *) profile=""; line="export PATH=\"$INSTALL_DIR:\$PATH\"" ;; esac say "" if [ -n "$profile" ] && [ -z "${KEELMARK_NO_MODIFY_PATH:-}" ]; then if ! grep -qsF "$INSTALL_DIR" "$profile"; then mkdir -p "$(dirname "$profile")" printf '\n# Keelmark\n%s\n' "$line" >> "$profile" fi say "Added Keelmark to your PATH in $profile (new terminals have it)." case "$profile" in *.fish) ;; *) say "To use \`keelmark\` in this terminal too, run: source $profile" ;; esac else say "Add Keelmark to your PATH by adding this line to your shell profile:" say " $line" fi fi say "" say "Next, in your app's folder (no account, config or keys needed):" say " $run check" say "" say "Or try it on a sample app first: $run check --demo" say "Use it from Claude Code: claude mcp add keelmark -- $INSTALL_DIR/keelmark mcp"