-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·183 lines (159 loc) · 4.77 KB
/
install.sh
File metadata and controls
executable file
·183 lines (159 loc) · 4.77 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
#
# git-ai Quick Install Script
#
# Usage:
# curl -fsSL https://raw.githubusercontent.com/mars167/git-ai-cli/main/install.sh | bash
#
# Or with options:
# curl -fsSL https://raw.githubusercontent.com/mars167/git-ai-cli/main/install.sh | bash -s -- --with-skill
#
# This script installs:
# 1. git-ai CLI tool (via npm)
# 2. Optionally: git-ai-mcp skill for AI agents
#
set -e
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
CYAN='\033[0;36m'
NC='\033[0m' # No Color
BOLD='\033[1m'
# Banner
print_banner() {
echo -e "${CYAN}"
echo ' ____ _ _ _ ___ '
echo ' / ___| (_) | |_ / \ |_ _|'
echo ' | | _ | | | __| ___ / _ \ | | '
echo ' | |_| | | | | |_ |___| / ___ \ | | '
echo ' \____| |_| \__| /_/ \_\___|'
echo -e "${NC}"
echo -e "${BOLD}Semantic Code Understanding for AI Agents${NC}"
echo ""
}
# Logging functions
info() {
echo -e "${BLUE}[INFO]${NC} $1"
}
success() {
echo -e "${GREEN}[OK]${NC} $1"
}
warn() {
echo -e "${YELLOW}[WARN]${NC} $1"
}
error() {
echo -e "${RED}[ERROR]${NC} $1"
exit 1
}
# Check if command exists
command_exists() {
command -v "$1" >/dev/null 2>&1
}
# Parse arguments
INSTALL_SKILL=false
GLOBAL_INSTALL=true
while [[ $# -gt 0 ]]; do
case $1 in
--with-skill|-s)
INSTALL_SKILL=true
shift
;;
--local|-l)
GLOBAL_INSTALL=false
shift
;;
--help|-h)
echo "Usage: install.sh [OPTIONS]"
echo ""
echo "Options:"
echo " --with-skill, -s Also install git-ai-mcp skill for AI agents"
echo " --local, -l Install locally instead of globally"
echo " --help, -h Show this help message"
exit 0
;;
*)
warn "Unknown option: $1"
shift
;;
esac
done
# Main installation
main() {
print_banner
# Check prerequisites
info "Checking prerequisites..."
if ! command_exists node; then
error "Node.js is required but not installed. Please install Node.js 18+ first."
fi
NODE_VERSION=$(node -v | cut -d'v' -f2 | cut -d'.' -f1)
if [ "$NODE_VERSION" -lt 18 ]; then
error "Node.js 18+ is required. Current version: $(node -v)"
fi
success "Node.js $(node -v) detected"
if ! command_exists npm; then
error "npm is required but not installed."
fi
success "npm $(npm -v) detected"
# Install git-ai
info "Installing git-ai CLI..."
if [ "$GLOBAL_INSTALL" = true ]; then
npm install -g @mars167/git-ai
success "git-ai installed globally"
else
npm install @mars167/git-ai
success "git-ai installed locally"
fi
# Verify installation
if command_exists git-ai; then
success "git-ai $(git-ai --version 2>/dev/null || echo 'installed')"
else
warn "git-ai command not found in PATH. You may need to restart your terminal."
fi
# Install skill if requested
if [ "$INSTALL_SKILL" = true ]; then
info "Installing git-ai-mcp skill..."
if ! command_exists npx; then
warn "npx not found. Skipping skill installation."
else
# Check if skills CLI is available
if npx skills --version >/dev/null 2>&1; then
npx skills add mars167/git-ai-cli@git-ai-mcp -g -y
success "git-ai-mcp skill installed"
else
info "Installing skills CLI..."
npx skills add mars167/git-ai-cli@git-ai-mcp -g -y
success "git-ai-mcp skill installed"
fi
fi
fi
# Print next steps
echo ""
echo -e "${GREEN}${BOLD}Installation Complete!${NC}"
echo ""
echo -e "${BOLD}Quick Start:${NC}"
echo ""
echo " 1. Initialize index in your project:"
echo -e " ${CYAN}cd your-project${NC}"
echo -e " ${CYAN}git-ai ai index --overwrite${NC}"
echo ""
echo " 2. Search code semantically:"
echo -e " ${CYAN}git-ai ai semantic \"user authentication\"${NC}"
echo ""
echo " 3. Analyze call graphs:"
echo -e " ${CYAN}git-ai ai graph callers functionName${NC}"
echo ""
if [ "$INSTALL_SKILL" = false ]; then
echo -e "${BOLD}For AI Agent Integration:${NC}"
echo ""
echo " Install the MCP skill for Claude/Cursor/etc:"
echo -e " ${CYAN}curl -fsSL https://raw.githubusercontent.com/mars167/git-ai-cli/main/install.sh | bash -s -- --with-skill${NC}"
echo ""
fi
echo -e "${BOLD}Documentation:${NC}"
echo " https://github.com/mars167/git-ai-cli"
echo ""
}
# Run main
main