-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·157 lines (132 loc) · 4.46 KB
/
install.sh
File metadata and controls
executable file
·157 lines (132 loc) · 4.46 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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
#!/usr/bin/env bash
set -euo pipefail
REPO="cloverhound/cucm-cli"
BINARY="cucm"
INSTALL_DIR="${INSTALL_DIR:-$HOME/.local/bin}"
SKILL_URL="https://raw.githubusercontent.com/${REPO}/main/skill/SKILL.md"
# Detect OS and architecture
OS="$(uname -s | tr '[:upper:]' '[:lower:]')"
ARCH="$(uname -m)"
case "$ARCH" in
x86_64) ARCH="amd64" ;;
aarch64|arm64) ARCH="arm64" ;;
*)
echo "Unsupported architecture: $ARCH" >&2
exit 1
;;
esac
case "$OS" in
darwin|linux) ;;
*)
echo "Unsupported OS: $OS (use install.ps1 for Windows)" >&2
exit 1
;;
esac
# Fetch latest release tag
echo "Fetching latest release..."
TAG="$(curl -fsSL "https://api.github.com/repos/${REPO}/releases/latest" | grep '"tag_name"' | sed -E 's/.*"tag_name": *"([^"]+)".*/\1/')"
if [[ -z "$TAG" ]]; then
echo "Failed to fetch latest release tag." >&2
exit 1
fi
echo "Installing cucm-cli ${TAG} (${OS}/${ARCH})..."
ARCHIVE="cucm-cli_${TAG#v}_${OS}_${ARCH}.tar.gz"
URL="https://github.com/${REPO}/releases/download/${TAG}/${ARCHIVE}"
TMPDIR="$(mktemp -d)"
# Download and extract
curl -fsSL "$URL" -o "${TMPDIR}/${ARCHIVE}"
tar -xzf "${TMPDIR}/${ARCHIVE}" -C "$TMPDIR"
# Install binary
mkdir -p "$INSTALL_DIR"
mv "${TMPDIR}/${BINARY}" "${INSTALL_DIR}/${BINARY}"
chmod +x "${INSTALL_DIR}/${BINARY}"
rm -rf "$TMPDIR"
echo "Installed to ${INSTALL_DIR}/${BINARY}"
# Check PATH
if ! echo "$PATH" | grep -q "$INSTALL_DIR"; then
echo ""
echo "NOTE: ${INSTALL_DIR} is not in your PATH."
echo "Add this to your shell profile:"
echo " export PATH=\"\$PATH:${INSTALL_DIR}\""
fi
# ── AI Assistant Skill Wizard ─────────────────────────────────────────────
#
# Reads user input from /dev/tty so the wizard works even when the script
# is piped from curl (where stdin is the pipe, not the terminal).
echo ""
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo " AI Assistant Skill Setup"
echo " Install the cucm-cli skill file for your AI coding assistants?"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
printf " Set up AI assistant integrations? [Y/n]: "
read -r SETUP_AI </dev/tty
if [[ "${SETUP_AI}" =~ ^[Nn]$ ]]; then
echo " Skipping AI assistant setup."
echo ""
echo "Run 'cucm --help' to get started."
exit 0
fi
# Download SKILL.md to a temp file
SKILL_TMP="$(mktemp)"
echo ""
echo " Fetching skill file..."
if ! curl -fsSL "$SKILL_URL" -o "$SKILL_TMP" 2>/dev/null; then
echo " Warning: could not fetch skill file from GitHub. Skipping AI setup." >&2
echo ""
echo "Run 'cucm --help' to get started."
exit 0
fi
# Helper: install skill for one assistant
# Usage: install_skill "<Display Name>" "<default destination path>"
install_skill() {
local name="$1"
local default_dest="$2"
echo ""
echo " ┌─ ${name}"
echo " │ Path: ${default_dest}"
printf " └─ Install? [Y/n/new path]: "
read -r resp </dev/tty
case "$resp" in
# Explicit skip
[Nn])
echo " Skipped."
return
;;
# Accept default (empty = Enter)
"")
dest="$default_dest"
;;
# Custom absolute path or ~/... path
/*)
dest="$resp"
;;
~*)
dest="${resp/#\~/$HOME}"
;;
# Anything else — treat as relative path under HOME
*)
dest="$HOME/$resp"
;;
esac
# Confirm custom path
if [[ "$dest" != "$default_dest" ]]; then
printf " Confirm destination: %s [Y/n]: " "$dest"
read -r confirm </dev/tty
if [[ "${confirm}" =~ ^[Nn]$ ]]; then
echo " Skipped."
return
fi
fi
mkdir -p "$(dirname "$dest")"
cp "$SKILL_TMP" "$dest"
echo " Installed → ${dest}"
}
# ── Assistants ────────────────────────────────────────────────────────────
install_skill "Claude Code" "${HOME}/.claude/skills/cucm-cli.md"
install_skill "Cursor" "${HOME}/.cursor/rules/cucm-cli.mdc"
install_skill "Gemini CLI" "${HOME}/.gemini/cucm-cli.md"
install_skill "Codex CLI" "${HOME}/.codex/cucm-cli.md"
# Cleanup
rm -f "$SKILL_TMP"
echo ""
echo "Run 'cucm --help' to get started."