-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
114 lines (112 loc) · 5.04 KB
/
install.sh
File metadata and controls
114 lines (112 loc) · 5.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#!/usr/bin/env bash
# eximagent installer — picks the right binary for your platform.
# Usage:
# curl -fsSL https://raw.githubusercontent.com/EximAgent/cli/main/install.sh | sh
# curl -fsSL https://raw.githubusercontent.com/EximAgent/cli/main/install.sh | EXIMAGENT_VERSION=v0.0.36 sh
set -euo pipefail
INSTALL_DIR="${EXIMAGENT_INSTALL_DIR:-${HOME}/.eximagent/bin}"
SYMLINK_DIR="${EXIMAGENT_SYMLINK_DIR:-/usr/local/bin}"
GITHUB_REPO="EximAgent/cli"
os=""
case "$(uname -s)" in
Darwin) os="darwin" ;;
Linux) os="linux" ;;
MINGW*|MSYS*|CYGWIN*)
echo "[eximagent] Windows detected — bash installer is best-effort; the supported path is:" >&2
echo " irm https://install.eximagent.ai/install.ps1 | iex (PowerShell)" >&2
os="windows" ;;
*) echo "[eximagent] unsupported OS: $(uname -s)" >&2; exit 1 ;;
esac
arch=""
case "$(uname -m)" in
arm64|aarch64) arch="arm64" ;;
x86_64|amd64) arch="amd64" ;;
*) echo "[eximagent] unsupported arch: $(uname -m)" >&2; exit 1 ;;
esac
target="${os}-${arch}"
[ "${os}" = "windows" ] && target="${target}.exe"
if [ -z "${EXIMAGENT_VERSION:-}" ]; then
if command -v curl >/dev/null 2>&1; then
tag=$(curl -fsSL "https://api.github.com/repos/${GITHUB_REPO}/releases/latest" | sed -n 's/.*"tag_name":[[:space:]]*"\([^"]*\)".*/\1/p' | head -1)
else
tag=$(wget -qO- "https://api.github.com/repos/${GITHUB_REPO}/releases/latest" | sed -n 's/.*"tag_name":[[:space:]]*"\([^"]*\)".*/\1/p' | head -1)
fi
[ -z "${tag}" ] && { echo "[eximagent] could not resolve latest release tag" >&2; exit 1; }
else
tag="${EXIMAGENT_VERSION}"
fi
url="https://github.com/${GITHUB_REPO}/releases/download/${tag}/eximagent-${target}"
mkdir -p "${INSTALL_DIR}"
dest="${INSTALL_DIR}/eximagent-${target}"
echo "[eximagent] fetching ${target} from ${tag}..." >&2
if command -v curl >/dev/null 2>&1; then
curl -fsSL "${url}" -o "${dest}"
elif command -v wget >/dev/null 2>&1; then
wget -qO "${dest}" "${url}"
else
echo "[eximagent] need curl or wget" >&2; exit 1
fi
chmod +x "${dest}"
shim="${INSTALL_DIR}/eximagent"
ln -sf "${dest}" "${shim}"
on_path=0
if [ -w "${SYMLINK_DIR}" ]; then
ln -sf "${shim}" "${SYMLINK_DIR}/eximagent"
echo "[eximagent] installed → ${SYMLINK_DIR}/eximagent" >&2
on_path=1
else
echo "[eximagent] installed → ${shim} (${SYMLINK_DIR} not writable)" >&2
# Auto-patch shell rc files so new shells find eximagent.
line="export PATH=\"${INSTALL_DIR}:\$PATH\""
for rc in "${HOME}/.zshrc" "${HOME}/.bashrc" "${HOME}/.profile" "${HOME}/.config/fish/config.fish"; do
[ -f "${rc}" ] || continue
case "${rc}" in
*config.fish) addition="set -gx PATH ${INSTALL_DIR} \$PATH" ;;
*) addition="${line}" ;;
esac
if ! grep -Fq "${INSTALL_DIR}" "${rc}" 2>/dev/null; then
printf '\n# added by eximagent installer\n%s\n' "${addition}" >> "${rc}"
echo "[eximagent] PATH patched in ${rc}" >&2
fi
done
# Try to expose binary to the current piped-sh process AND its parent for chained `&& eximagent login`.
export PATH="${INSTALL_DIR}:${PATH}"
echo "[eximagent] for THIS shell, run: export PATH=\"${INSTALL_DIR}:\$PATH\" (or open a new terminal)" >&2
fi
# Self-check: binary version must match the tag we just resolved.
# Catches "release mirrored to wrong repo" / "stale CDN" / "PAT lost write" silent-stale failures.
installed_version=$("${shim}" --version 2>/dev/null | head -1 | tr -d '\r\n')
case "${installed_version}" in
*"${tag#v}"*|*"${tag}"*) echo "[eximagent] version OK (${installed_version} matches ${tag})" >&2 ;;
*)
echo "[eximagent] !! VERSION MISMATCH: binary reports '${installed_version}', expected '${tag}'." >&2
echo "[eximagent] !! The release on github.com/${GITHUB_REPO} is out of sync with the source repo." >&2
echo "[eximagent] !! Report this to the EximAgent team with the line above." >&2 ;;
esac
if [ "${EXIMAGENT_NO_LOGIN:-}" != "1" ]; then
echo "[eximagent] starting login (opt out with EXIMAGENT_NO_LOGIN=1)..." >&2
"${shim}" login || echo "[eximagent] login did not complete; run 'eximagent login' from a new shell" >&2
fi
# Drop SKILL.md to host-agent directories (parity with the prior npm postinstall behaviour).
# Skip with EXIMAGENT_NO_SKILL=1; override source with EXIMAGENT_SKILL_URL.
if [ "${EXIMAGENT_NO_SKILL:-}" != "1" ]; then
skill_url="${EXIMAGENT_SKILL_URL:-https://go-api.eximagent.ai/api/cli/skill}"
if command -v curl >/dev/null 2>&1; then
skill_content=$(curl -fsSL "${skill_url}" 2>/dev/null || true)
else
skill_content=$(wget -qO- "${skill_url}" 2>/dev/null || true)
fi
if [ -n "${skill_content}" ]; then
drop_skill() {
mkdir -p "$(dirname "$1")"
printf "%s" "${skill_content}" > "$1"
echo "[eximagent] skill -> $2: $1" >&2
}
drop_skill "${HOME}/.claude/skills/eximagent/SKILL.md" "Claude Code"
drop_skill "${HOME}/.codex/skills/eximagent/SKILL.md" "Codex"
drop_skill "${HOME}/.cursor/rules/eximagent.mdc" "Cursor"
drop_skill "${HOME}/.agents/skills/eximagent/SKILL.md" "Universal"
else
echo "[eximagent] could not fetch skill from ${skill_url} — skip with EXIMAGENT_NO_SKILL=1" >&2
fi
fi