Files
myclaude/install.sh
cexll 4bc9ffa907 fix(cli): resolve process hang after install and sync version with tag
- Add process.stdin.pause() in cleanup() to properly exit event loop
- Pass tag via CODEAGENT_WRAPPER_VERSION env to install.sh
- Support versioned release URL in install.sh

Generated with SWE-Agent.ai

Co-Authored-By: SWE-Agent.ai <noreply@swe-agent.ai>
2026-01-28 15:08:24 +08:00

89 lines
2.6 KiB
Bash

#!/bin/bash
set -e
if [ -z "${SKIP_WARNING:-}" ]; then
echo "⚠️ WARNING: install.sh is LEGACY and will be removed in future versions."
echo "Please use the new installation method:"
echo " npx github:cexll/myclaude"
echo ""
echo "Set SKIP_WARNING=1 to bypass this message"
echo "Continuing with legacy installation in 5 seconds..."
sleep 5
fi
# Detect platform
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
ARCH=$(uname -m)
# Normalize architecture names
case "$ARCH" in
x86_64) ARCH="amd64" ;;
aarch64|arm64) ARCH="arm64" ;;
*) echo "Unsupported architecture: $ARCH" >&2; exit 1 ;;
esac
# Build download URL
REPO="cexll/myclaude"
VERSION="${CODEAGENT_WRAPPER_VERSION:-latest}"
BINARY_NAME="codeagent-wrapper-${OS}-${ARCH}"
if [ "$VERSION" = "latest" ]; then
URL="https://github.com/${REPO}/releases/latest/download/${BINARY_NAME}"
else
URL="https://github.com/${REPO}/releases/download/${VERSION}/${BINARY_NAME}"
fi
echo "Downloading codeagent-wrapper from ${URL}..."
if ! curl -fsSL "$URL" -o /tmp/codeagent-wrapper; then
echo "ERROR: failed to download binary" >&2
exit 1
fi
INSTALL_DIR="${INSTALL_DIR:-$HOME/.claude}"
BIN_DIR="${INSTALL_DIR}/bin"
mkdir -p "$BIN_DIR"
mv /tmp/codeagent-wrapper "${BIN_DIR}/codeagent-wrapper"
chmod +x "${BIN_DIR}/codeagent-wrapper"
if "${BIN_DIR}/codeagent-wrapper" --version >/dev/null 2>&1; then
echo "codeagent-wrapper installed successfully to ${BIN_DIR}/codeagent-wrapper"
else
echo "ERROR: installation verification failed" >&2
exit 1
fi
# Auto-add to shell config files with idempotency
if [[ ":${PATH}:" != *":${BIN_DIR}:"* ]]; then
echo ""
echo "WARNING: ${BIN_DIR} is not in your PATH"
# Detect shell and set config files
if [ -n "$ZSH_VERSION" ]; then
RC_FILE="$HOME/.zshrc"
PROFILE_FILE="$HOME/.zprofile"
else
RC_FILE="$HOME/.bashrc"
PROFILE_FILE="$HOME/.profile"
fi
# Idempotent add: check if complete export statement already exists
EXPORT_LINE="export PATH=\"${BIN_DIR}:\$PATH\""
FILES_TO_UPDATE=("$RC_FILE" "$PROFILE_FILE")
for FILE in "${FILES_TO_UPDATE[@]}"; do
if [ -f "$FILE" ] && grep -qF "${EXPORT_LINE}" "$FILE" 2>/dev/null; then
echo " ${BIN_DIR} already in ${FILE}, skipping."
else
echo " Adding to ${FILE}..."
echo "" >> "$FILE"
echo "# Added by myclaude installer" >> "$FILE"
echo "${EXPORT_LINE}" >> "$FILE"
fi
done
echo " Done. Restart your shell or run:"
echo " source ${PROFILE_FILE}"
echo " source ${RC_FILE}"
echo ""
fi