Home
About
Blog
Products
Forum
Support
Contact
Sunbelt Computer Software
PL/B Language Development and Support
Home
About
Blog
Products
Forum
Support
Contact
kit/install.sh at master · mark3labs/kit · GitHub
Skip to content
Navigation Menu
Sign in
Products
Platform
GitHub
Repository hosting, code review, and collaboration
Copilot
AI coding agent for tasks, projects and automated work
Build & Ship
Actions
CI/CD and automation
Code Quality
Quality analysis, fixes, and enforcement
Codespaces
Cloud development environments
Secure
Code Security
Vulnerability detection and remediation
Secret Protection
Secret scanning and leak prevention
All Features
Developers
Learn
Documentation
Training
Certifications
Build
Build with Copilot
Customize Copilot
Integrations
Explore
Trending repos
GitHub Sponsors
Events
Changelog
Changelog
Your source for the latest features, improvements, and fixes across GitHub products, all in one place.
Businesses
By Stage
Enterprises
Team
Startups
Nonprofits
By Industry
Healthcare
Financial services
Manufacturing
Government
See all industries
Evaluate GitHub
Why GitHub
Customer Stories
Business insights
Trust Center
Add-ons
GitHub Advanced Security
Enterprise-grade code security
Copilot for business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Resources
Learn & Connect
Documentation
Resource center
Blog
Events & webinars
Community Forum
Customer Stories
Integrations
Support
Customer support
Training
GitHub Status
Company
About
Partners
Changelog
GitHub Universe
GitHub Universe
The event for developers, by developers — talks, workshops, and what’s next for GitHub.
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
mark3labs
kit
Repository navigation
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
More
items
Files
Expand file tree
master
Breadcrumbs
kit
/
install.sh
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
executable file
·
260 lines (217 loc) · 9.76 KB
master
Breadcrumbs
kit
/
install.sh
Copy path
Top
File metadata and controls
Code
Blame
executable file
·
260 lines (217 loc) · 9.76 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
#!
/usr/bin/env bash
#
Kit install script
#
Usage:
#
curl -fsSL https://raw.githubusercontent.com/mark3labs/kit/master/install.sh | bash
#
bash install.sh [--bin-dir <dir>] [--version <tag>] [--no-provider-check]
set
-euo pipefail
#
── Colour helpers ──────────────────────────────────────────────────────────
if
[
-t
1 ]
&&
command
-v tput
&
>
/dev/null
&&
tput colors
&
>
/dev/null
;
then
BOLD=
$(
tput bold
)
;
RESET=
$(
tput sgr0
)
RED=
$(
tput setaf 1
)
;
GREEN=
$(
tput setaf 2
)
YELLOW=
$(
tput setaf 3
)
;
CYAN=
$(
tput setaf 6
)
else
BOLD=
"
"
;
RESET=
"
"
;
RED=
"
"
;
GREEN=
"
"
;
YELLOW=
"
"
;
CYAN=
"
"
fi
info
() {
printf
"
%s %s%s\n
"
"
${CYAN}
→
${RESET}
"
"
$*
"
"
${RESET}
"
;
}
success
() {
printf
"
%s %s%s\n
"
"
${GREEN}
✓
${RESET}
"
"
$*
"
"
${RESET}
"
;
}
warn
() {
printf
"
%s %s%s\n
"
"
${YELLOW}
⚠
${RESET}
"
"
$*
"
"
${RESET}
"
;
}
die
() {
printf
"
%s %s%s\n
"
>&2
"
${RED}
✗
${RESET}
"
"
$*
"
"
${RESET}
"
;
exit
1
;
}
header
() {
printf
"
\n%s%s%s\n\n
"
"
${BOLD}
"
"
$*
"
"
${RESET}
"
;
}
#
── Defaults ────────────────────────────────────────────────────────────────
REPO=
"
mark3labs/kit
"
BIN_NAME=
"
kit
"
VERSION=
"
${KIT_VERSION
:-
}
"
#
empty = latest release tag
BIN_DIR=
"
${KIT_BIN_DIR
:-
}
"
#
empty = auto-detect
CHECK_PROVIDER=true
#
── Argument parsing ─────────────────────────────────────────────────────────
while
[[
$#
-gt
0 ]]
;
do
case
"
$1
"
in
--bin-dir)
[[
$#
-ge
2 ]]
||
die
"
--bin-dir needs a value
"
BIN_DIR=
"
$2
"
;
shift
2 ;;
--version)
[[
$#
-ge
2 ]]
||
die
"
--version needs a value
"
VERSION=
"
$2
"
;
shift
2 ;;
--no-provider-check) CHECK_PROVIDER=false
;
shift
;;
-h|--help)
cat
<<
EOF
Usage: install.sh [options]
Options:
--bin-dir <dir> Directory to install kit into (default: auto-detect, ~/.local/bin)
--version <tag> Release tag to install (default: latest)
--no-provider-check Skip the LLM provider API key reminder
-h, --help Show this help
Environment:
KIT_BIN_DIR Same as --bin-dir
KIT_VERSION Same as --version
EOF
exit
0 ;;
*
) die
"
Unknown option:
$1
"
;;
esac
done
#
── Platform detection ───────────────────────────────────────────────────────
detect_platform
() {
local
os arch
case
"
$(
uname -s
)
"
in
Linux) os=
"
linux
"
;;
Darwin) os=
"
darwin
"
;;
MINGW
*
|MSYS
*
|CYGWIN
*
)
die
"
Windows is not supported by this script. Use 'npm install -g @mark3labs/kit' or download the zip from https://github.com/
${REPO}
/releases
"
;;
*
) die
"
Unsupported OS:
$(
uname -s
)
"
;;
esac
case
"
$(
uname -m
)
"
in
x86_64|amd64) arch=
"
amd64
"
;;
aarch64|arm64) arch=
"
arm64
"
;;
*
) die
"
Unsupported architecture:
$(
uname -m
)
"
;;
esac
echo
"
${os}
_
${arch}
"
}
#
── Resolve install directory ─────────────────────────────────────────────────
resolve_bin_dir
() {
if
[[
-n
"
$BIN_DIR
"
]]
;
then
echo
"
$BIN_DIR
"
return
fi
#
Prefer a writable directory that already exists
local
candidates=(
"
$HOME
/.local/bin
"
"
$HOME
/bin
"
"
/usr/local/bin
"
)
for
dir
in
"
${candidates[@]}
"
;
do
if
[[
-d
"
$dir
"
&&
-w
"
$dir
"
]]
;
then
echo
"
$dir
"
return
fi
done
#
Fall back to ~/.local/bin and create it
echo
"
$HOME
/.local/bin
"
}
#
── Fetch helper (stdout) ─────────────────────────────────────────────────────
fetch
() {
local
url=
"
$1
"
if
command
-v curl
&
>
/dev/null
;
then
curl -fsSL
"
$url
"
elif
command
-v wget
&
>
/dev/null
;
then
wget -qO-
"
$url
"
else
die
"
Neither curl nor wget is available. Install one and retry.
"
fi
}
#
── Fetch latest tag from GitHub ──────────────────────────────────────────────
latest_version
() {
local
tag
tag=
$(
fetch
"
https://api.github.com/repos/
${REPO}
/releases/latest
"
\
|
grep
'
"tag_name"
'
|
head -1
|
sed
'
s/.*"tag_name": *"\(.*\)".*/\1/
'
)
||
true
[[
-n
"
$tag
"
]]
||
die
"
Could not determine latest release. Use --version to pin one.
"
echo
"
$tag
"
}
#
── Download helper ───────────────────────────────────────────────────────────
download
() {
local
url=
"
$1
"
dest=
"
$2
"
if
command
-v curl
&
>
/dev/null
;
then
curl -fsSL
"
$url
"
-o
"
$dest
"
elif
command
-v wget
&
>
/dev/null
;
then
wget -q
"
$url
"
-O
"
$dest
"
else
die
"
Neither curl nor wget is available. Install one and retry.
"
fi
}
#
── Checksum helper ──────────────────────────────────────────────────────────
verify_checksum
() {
local
file=
"
$1
"
asset=
"
$2
"
version=
"
$3
"
tmp_dir=
"
$4
"
local
checksums=
"
${tmp_dir}
/checksums.txt
"
local
url=
"
https://github.com/
${REPO}
/releases/download/
${version}
/checksums.txt
"
download
"
$url
"
"
$checksums
"
2>
/dev/null
||
\
die
"
Could not download checksums.txt for
${version}
; refusing to install an unverified binary
"
local
expected
expected=
$(
awk -v asset=
"
$asset
"
'
$2 == asset { print $1; exit }
'
"
$checksums
"
)
[[
-n
"
$expected
"
]]
||
\
die
"
No checksum found for
${asset}
; refusing to install an unverified binary
"
local
actual
if
command
-v sha256sum
&
>
/dev/null
;
then
actual=
$(
sha256sum
"
$file
"
|
awk
'
{print $1}
'
)
elif
command
-v shasum
&
>
/dev/null
;
then
actual=
$(
shasum -a 256
"
$file
"
|
awk
'
{print $1}
'
)
else
die
"
SHA-256 verification requires sha256sum or shasum
"
fi
[[
"
$actual
"
==
"
$expected
"
]]
||
die
"
Checksum mismatch for
${asset}
"
success
"
Verified checksum
"
}
#
── Install via pre-built release binary ─────────────────────────────────────
TMP_DIR=
"
"
cleanup
() { [[
-n
"
$TMP_DIR
"
]]
&&
rm -rf
"
$TMP_DIR
"
;
}
trap
cleanup EXIT
install_from_release
() {
local
version=
"
$1
"
platform=
"
$2
"
bin_dir=
"
$3
"
#
GoReleaser asset name pattern: kit_<version-without-v>_<os>_<arch>.tar.gz
local
asset=
"
${BIN_NAME}
_
${version
#
v}
_
${platform}
.tar.gz
"
local
url=
"
https://github.com/
${REPO}
/releases/download/
${version}
/
${asset}
"
TMP_DIR=
$(
mktemp -d
)
info
"
Downloading
${asset}
(
${version}
)…
"
download
"
$url
"
"
${TMP_DIR}
/
${asset}
"
2>
/dev/null
||
\
die
"
Could not download release asset:
${url}
"
verify_checksum
"
${TMP_DIR}
/
${asset}
"
"
$asset
"
"
$version
"
"
$TMP_DIR
"
command
-v tar
&
>
/dev/null
||
die
"
tar is required to extract
${asset}
"
tar -xzf
"
${TMP_DIR}
/
${asset}
"
-C
"
$TMP_DIR
"
local
extracted=
"
${TMP_DIR}
/
${BIN_NAME}
"
if
[[
!
-f
"
$extracted
"
]]
;
then
extracted=
$(
find
"
$TMP_DIR
"
-type f -name
"
${BIN_NAME}
"
|
head -n 1
)
fi
[[
-n
"
$extracted
"
&&
-f
"
$extracted
"
]]
||
die
"
Archive did not contain
${BIN_NAME}
"
mkdir -p
"
$bin_dir
"
||
die
"
Could not create
${bin_dir}
. Use --bin-dir to choose another directory.
"
[[
-w
"
$bin_dir
"
]]
||
die
"
${bin_dir}
is not writable. Use --bin-dir or run with sudo.
"
install -m 0755
"
$extracted
"
"
${bin_dir}
/
${BIN_NAME}
"
success
"
Installed
${BIN_NAME}
→
${bin_dir}
/
${BIN_NAME}
"
}
#
── PATH nudge ────────────────────────────────────────────────────────────────
check_path
() {
local
bin_dir=
"
$1
"
if
!
echo
"
$PATH
"
|
tr
'
:
'
'
\n
'
|
grep -qx
"
$bin_dir
"
;
then
echo
"
"
warn
"
${bin_dir}
is not on your
\$
PATH.
"
echo
"
Add this line to your shell rc file:
"
echo
"
"
printf
"
%sexport PATH=
\"
%s:
\$
PATH
\"
%s\n
"
"
${BOLD}
"
"
$bin_dir
"
"
${RESET}
"
echo
"
"
echo
"
Then reload your shell: source ~/.bashrc (or ~/.zshrc)
"
fi
}
#
── Provider API key reminder ─────────────────────────────────────────────────
check_provider
() {
if
[[
"
$CHECK_PROVIDER
"
==
false
]]
;
then
return
;
fi
local
keys=(ANTHROPIC_API_KEY OPENAI_API_KEY GOOGLE_API_KEY GEMINI_API_KEY OPENROUTER_API_KEY)
for
key
in
"
${keys[@]}
"
;
do
if
[[
-n
"
${
!
key
:-
}
"
]]
;
then
success
"
${key}
is set
"
return
fi
done
echo
"
"
warn
"
No LLM provider API key found.
"
echo
"
Export a key for your preferred provider, for example:
"
echo
"
"
printf
"
%sexport ANTHROPIC_API_KEY=
\"
sk-ant-...
\"
%s\n
"
"
${BOLD}
"
"
${RESET}
"
echo
"
"
echo
"
Or log in interactively: kit auth login anthropic
"
echo
"
See https://github.com/
${REPO}
#readme for all providers.
"
}
#
── Main ──────────────────────────────────────────────────────────────────────
main
() {
header
"
Installing Kit
"
local
platform
platform=
$(
detect_platform
)
info
"
Detected platform:
${platform}
"
local
bin_dir
bin_dir=
$(
resolve_bin_dir
)
if
[[
-z
"
$VERSION
"
]]
;
then
info
"
Resolving latest release…
"
VERSION=
$(
latest_version
)
fi
[[
"
$VERSION
"
==
v
*
]]
||
VERSION=
"
v
${VERSION}
"
info
"
Version:
${VERSION}
"
install_from_release
"
$VERSION
"
"
$platform
"
"
$bin_dir
"
check_path
"
$bin_dir
"
check_provider
echo
"
"
success
"
Done! Run
${BOLD}
kit
${RESET}${GREEN}
to start.
${RESET}
"
echo
"
"
}
main
"
$@
"
You can’t perform that action at this time.