-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
183 lines (150 loc) · 5.1 KB
/
install.sh
File metadata and controls
183 lines (150 loc) · 5.1 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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
#!/bin/bash
# Tow CLI Installer
# by neurosam.AI — https://neurosam.ai
#
# Usage:
# curl -fsSL https://raw.githubusercontent.com/neurosamAI/tow-cli/main/install.sh | bash
#
# With a specific version:
# curl -fsSL https://raw.githubusercontent.com/neurosamAI/tow-cli/main/install.sh | bash -s -- v0.1.0
#
# With AI integration (Claude Code + MCP):
# curl -fsSL https://raw.githubusercontent.com/neurosamAI/tow-cli/main/install.sh | WITH_AI=true bash
set -e
# ─── Config ───
REPO="neurosamAI/tow-cli"
INSTALL_DIR="/usr/local/bin"
BINARY_NAME="tow"
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
BLUE='\033[0;34m'
CYAN='\033[0;36m'
BOLD='\033[1m'
NC='\033[0m'
# ─── Functions ───
info() { echo -e "${BLUE}[info]${NC} $1"; }
success() { echo -e "${GREEN}[✓]${NC} $1"; }
error() { echo -e "${RED}[error]${NC} $1" >&2; exit 1; }
detect_platform() {
local os arch
case "$(uname -s)" in
Darwin) os="darwin" ;;
Linux) os="linux" ;;
*) error "Unsupported OS: $(uname -s). Tow supports macOS and Linux." ;;
esac
case "$(uname -m)" in
x86_64|amd64) arch="amd64" ;;
aarch64|arm64) arch="arm64" ;;
*) error "Unsupported architecture: $(uname -m). Tow supports amd64 and arm64." ;;
esac
echo "${os}-${arch}"
}
get_latest_version() {
local version
version=$(curl -fsSL "https://api.github.com/repos/${REPO}/releases/latest" 2>/dev/null \
| grep '"tag_name"' | head -1 | sed 's/.*"tag_name": *"//;s/".*//')
if [ -z "$version" ]; then
error "Failed to fetch latest version. Check your internet connection."
fi
echo "$version"
}
download_and_install() {
local version="$1"
local platform="$2"
local url="https://github.com/${REPO}/releases/download/${version}/tow-${platform}"
local tmp_file
tmp_file=$(mktemp)
info "Downloading Tow ${version} for ${platform}..."
if ! curl -fsSL -o "$tmp_file" "$url"; then
rm -f "$tmp_file"
error "Download failed. URL: $url"
fi
chmod +x "$tmp_file"
# Verify it's a valid binary
if ! "$tmp_file" --version >/dev/null 2>&1; then
rm -f "$tmp_file"
error "Downloaded binary is invalid or corrupted."
fi
# Install
info "Installing to ${INSTALL_DIR}/${BINARY_NAME}..."
if [ -w "$INSTALL_DIR" ]; then
mv "$tmp_file" "${INSTALL_DIR}/${BINARY_NAME}"
else
sudo mv "$tmp_file" "${INSTALL_DIR}/${BINARY_NAME}"
fi
success "Tow ${version} installed successfully!"
}
setup_ai_integration() {
# Only if user opted in
if [ "${WITH_AI:-false}" != "true" ]; then
echo ""
info "AI integration available! Run in your project:"
echo -e " ${CYAN}tow init --with-ai${NC} # Generate Claude Code skill + MCP config"
echo ""
if command -v claude >/dev/null 2>&1; then
info "Or add MCP server to Claude Code directly:"
echo -e " ${CYAN}claude mcp add tow tow mcp-server${NC}"
fi
return
fi
# Auto-setup Claude Code skill if .claude directory exists
if [ -d ".claude" ] || [ -d "$HOME/.claude" ]; then
local skill_dir
if [ -d ".claude" ]; then
skill_dir=".claude/skills"
else
skill_dir="$HOME/.claude/skills"
fi
if [ ! -f "$skill_dir/tow-deploy.md" ]; then
info "Setting up Claude Code skill..."
mkdir -p "$skill_dir"
curl -fsSL "https://raw.githubusercontent.com/${REPO}/main/integrations/claude-skill/tow-deploy.md" \
-o "$skill_dir/tow-deploy.md" 2>/dev/null && \
success "Claude Code skill installed at $skill_dir/tow-deploy.md" || true
fi
fi
if command -v claude >/dev/null 2>&1; then
info "Adding Tow MCP server to Claude Code..."
claude mcp add tow tow mcp-server 2>/dev/null && \
success "MCP server registered with Claude Code" || true
fi
}
# ─── Main ───
main() {
echo ""
echo -e "${BOLD}${CYAN} ⚓ Tow Installer${NC}"
echo -e " ${BLUE}by Murry Jeong (comchangs) — neurosam.AI${NC}"
echo ""
# Determine version
local version="${1:-}"
if [ -z "$version" ]; then
info "Fetching latest version..."
version=$(get_latest_version)
fi
# Detect platform
local platform
platform=$(detect_platform)
info "Platform: ${platform}"
info "Version: ${version}"
echo ""
# Download and install
download_and_install "$version" "$platform"
# Verify installation
local installed_version
installed_version=$("${INSTALL_DIR}/${BINARY_NAME}" --version 2>&1 | head -1)
success "Installed: ${installed_version}"
# AI integration setup
echo ""
setup_ai_integration
# Print next steps
echo ""
echo -e "${BOLD}Next steps:${NC}"
echo -e " ${CYAN}cd your-project${NC}"
echo -e " ${CYAN}tow init${NC} # Auto-detect and generate config"
echo -e " ${CYAN}tow auto -e dev -m app${NC} # Deploy!"
echo ""
echo -e " Docs: ${BLUE}https://tow-cli.neurosam.ai${NC}"
echo ""
}
main "$@"