#!/bin/sh # MeowByte Code installer for macOS and Linux. # # curl -fsSL https://ai.meowbyte.net/install.sh | sh # # Downloads the standalone `meowbyte` binary for this machine, checks it against the SHA-256 # published in the release manifest, and installs it to ~/.meowbyte/bin (or $MEOWBYTE_INSTALL_DIR). # Nothing else is required - no Node, no package manager. On Windows, use install.ps1 instead. set -eu API="${MEOWBYTE_API_URL:-https://backend.meowbyte.net}" DIR="${MEOWBYTE_INSTALL_DIR:-$HOME/.meowbyte/bin}" fail() { printf 'meowbyte install: %s\n' "$1" >&2; exit 1; } case "$(uname -s)" in Linux) os=linux ;; Darwin) os=darwin ;; *) fail "unsupported system $(uname -s). On Windows, run: irm https://ai.meowbyte.net/install.ps1 | iex" ;; esac case "$(uname -m)" in x86_64 | amd64) arch=x64 ;; arm64 | aarch64) arch=arm64 ;; *) fail "unsupported CPU $(uname -m)" ;; esac # An x64 shell running under Rosetta on Apple Silicon should still get the native arm64 build. if [ "$os" = darwin ] && [ "$arch" = x64 ] && [ "$(sysctl -n sysctl.proc_translated 2>/dev/null || echo 0)" = 1 ]; then arch=arm64 fi key="$os-$arch" download() { if command -v curl >/dev/null 2>&1; then curl -fsSL "$1" -o "$2" elif command -v wget >/dev/null 2>&1; then wget -qO "$2" "$1" else fail "needs curl or wget" fi } tmp="$(mktemp -d)" trap 'rm -rf "$tmp"' EXIT download "$API/cli/releases/latest.json" "$tmp/latest.json" || fail "couldn't reach $API" # The manifest is tiny and fixed-shape; parse it without requiring jq. manifest="$(tr -d '\n\r\t' < "$tmp/latest.json")" version="$(printf '%s' "$manifest" | sed -n 's/^[^{]*{ *"version" *: *"\([^"]*\)".*/\1/p')" entry="$(printf '%s' "$manifest" | sed -n "s/.*\"$key\" *: *{\([^}]*\)}.*/\1/p")" path="$(printf '%s' "$entry" | sed -n 's/.*"path" *: *"\([^"]*\)".*/\1/p')" sha="$(printf '%s' "$entry" | sed -n 's/.*"sha256" *: *"\([^"]*\)".*/\1/p')" [ -n "$path" ] && [ -n "$sha" ] || fail "no build for $key in the latest release" printf 'Downloading MeowByte Code %s for %s...\n' "$version" "$key" download "$API/cli/releases/$path" "$tmp/meowbyte" || fail "download failed" if command -v sha256sum >/dev/null 2>&1; then actual="$(sha256sum "$tmp/meowbyte" | cut -d' ' -f1)" else actual="$(shasum -a 256 "$tmp/meowbyte" | cut -d' ' -f1)" fi [ "$actual" = "$sha" ] || fail "the download didn't match its published checksum - not installing it" mkdir -p "$DIR" mv "$tmp/meowbyte" "$DIR/meowbyte" chmod +x "$DIR/meowbyte" printf 'Installed %s/meowbyte\n' "$DIR" case ":$PATH:" in *":$DIR:"*) ;; *) line="export PATH=\"$DIR:\$PATH\"" case "${SHELL:-}" in */zsh) rc="$HOME/.zshrc" ;; */bash) if [ "$os" = darwin ]; then rc="$HOME/.bash_profile"; else rc="$HOME/.bashrc"; fi ;; *) rc="$HOME/.profile" ;; esac if ! grep -qsF "$line" "$rc"; then printf '\n# MeowByte Code\n%s\n' "$line" >> "$rc" printf 'Added %s to PATH in %s - open a new terminal, or run: %s\n' "$DIR" "$rc" "$line" fi ;; esac printf '\nNext: run `meowbyte login`, then `meowbyte` inside a project.\n'