Repository navigation
Expand file tree
/
Copy pathinstall.sh
More file actions
186 lines (166 loc) · 7.31 KB
/
Copy pathinstall.sh
File metadata and controls
186 lines (166 loc) · 7.31 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
184
185
186
#!/bin/sh
# Installs the Proofline command-line client.
#
# curl -fsSL https://proofline.sh/cli | sh
# curl -fsSL https://proofline.sh/cli | sh -s -- --setup
#
# It downloads its matching release for this machine from proofline.sh over
# HTTPS, checks it against the release's SHA256SUMS, and puts `proofline` in
# ~/.local/bin, or in PROOFLINE_INSTALL_DIR when that is set. PROOFLINE_VERSION
# selects another release.
#
# Every statement is inside a function and the last line calls it, so a
# download cut short runs nothing.
set -eu
PROOFLINE_CLI=https://proofline.sh/cli
PROOFLINE_INSTALLER_VERSION=0.13.0
say() {
printf 'proofline install: %s\n' "$*" >&2
}
refuse() {
say "$*"
exit 1
}
need() {
command -v "$1" >/dev/null 2>&1 || refuse "this installer needs $1, which is not on PATH"
}
# curl refuses any address that is not HTTPS, a redirect included, and any TLS
# older than 1.2.
fetch() {
curl --proto '=https' --tlsv1.2 --fail --silent --show-error --location "$@"
}
# The release target for this machine, one of the four a release publishes.
target() {
os=$(uname -s)
arch=$(uname -m)
case "$os" in
Linux) os=unknown-linux-musl ;;
Darwin)
os=apple-darwin
# A shell under Rosetta reports x86_64 on Apple silicon. The native
# build is the one to install there.
if [ "$arch" = x86_64 ] && [ "$(sysctl -n sysctl.proc_translated 2>/dev/null || true)" = 1 ]; then
arch=arm64
fi
;;
*) refuse "no Proofline release is built for $os; set PROOFLINE_TOKEN and call the API, or build https://github.com/prooflinedev/cli from source" ;;
esac
case "$arch" in
x86_64 | amd64) arch=x86_64 ;;
aarch64 | arm64) arch=aarch64 ;;
*) refuse "no Proofline release is built for $arch on $(uname -s)" ;;
esac
printf '%s-%s\n' "$arch" "$os"
}
sha256() {
if command -v sha256sum >/dev/null 2>&1; then
sha256sum "$1" | cut -d ' ' -f 1
elif command -v shasum >/dev/null 2>&1; then
shasum -a 256 "$1" | cut -d ' ' -f 1
else
refuse "this installer needs sha256sum or shasum to check the download"
fi
}
main() {
setup=false
case "$#:$*" in
0:) ;;
1:--setup) setup=true ;;
1:--help)
say "usage: curl -fsSL https://proofline.sh/cli | sh -s -- [--setup]"
say "--setup registers MCP in Claude Code, Cursor and Codex, then runs proofline init to sign in, wait for the GitHub App and print the setup brief; it needs git"
return
;;
*) refuse "unknown arguments; use --setup for coding-agent installation or --help for usage" ;;
esac
# Agent registration runs git to keep agent configuration out of Git working
# trees. Check before downloading, so a machine without it gets nothing.
if [ "$setup" = true ] && ! command -v git >/dev/null 2>&1; then
refuse "coding-agent setup needs git, which is not on PATH; nothing was installed; install Git and rerun this command, or omit --setup to install only the CLI"
fi
need curl
need tar
need uname
need mktemp
target=$(target)
if [ -n "${PROOFLINE_VERSION:-}" ]; then
version=${PROOFLINE_VERSION#v}
else
version=$PROOFLINE_INSTALLER_VERSION
fi
printf '%s\n' "$version" | grep -Eqx '[0-9]+\.[0-9]+\.[0-9]+' ||
refuse "the release version is not a version number: $version"
directory=${PROOFLINE_INSTALL_DIR:-${HOME:?set HOME or PROOFLINE_INSTALL_DIR}/.local/bin}
archive=proofline-$target.tar.gz
release=$PROOFLINE_CLI/download/$version
work=$(mktemp -d)
trap 'rm -rf "$work"' EXIT
trap 'exit 130' INT TERM
say "downloading proofline $version for $target"
fetch --output "$work/$archive" "$release/$archive" ||
refuse "could not download $release/$archive"
fetch --output "$work/SHA256SUMS" "$release/SHA256SUMS" ||
refuse "could not download $release/SHA256SUMS"
expected=$(awk -v name="$archive" '$2 == name || $2 == "*" name { print $1 }' "$work/SHA256SUMS")
[ -n "$expected" ] || refuse "SHA256SUMS for $version lists no $archive"
actual=$(sha256 "$work/$archive")
[ "$actual" = "$expected" ] ||
refuse "the download does not match SHA256SUMS ($actual, expected $expected); nothing was installed"
tar -xzf "$work/$archive" -C "$work" proofline ||
refuse "$archive does not contain proofline"
chmod 755 "$work/proofline"
if [ "$setup" = true ]; then
{ "$work/proofline" agent install claude-code --print >/dev/null &&
"$work/proofline" init --help >/dev/null; } ||
refuse "release $version does not support one-command setup, which needs proofline init; install the latest release"
fi
mkdir -p "$directory" || refuse "could not create $directory"
# Copy beside the destination and rename over it, so a running proofline
# is never overwritten in place and an interrupted copy leaves the old one.
cp "$work/proofline" "$directory/.proofline.$$" || refuse "could not write to $directory"
mv -f "$directory/.proofline.$$" "$directory/proofline"
say "installed $("$directory/proofline" --version) at $directory/proofline"
binary=proofline
case ":${PATH:-}:" in
*":$directory:"*) ;;
*)
binary=$directory/proofline
say "$directory is not on PATH; add it to run proofline by name"
# The file the login shell reads when a terminal opens. Terminal on macOS
# starts Bash as a login shell, which skips ~/.bashrc.
# The tilde is shown to the reader, not expanded.
# shellcheck disable=SC2088
case "${SHELL:-}:$(uname -s)" in
*/zsh:*) profile='~/.zshrc' ;;
*/bash:Darwin) profile='~/.bash_profile' ;;
*/bash:*) profile='~/.bashrc' ;;
*) profile="your shell's startup file" ;;
esac
say "add this line to $profile, and run it here to use proofline in this terminal:"
say " export PATH=\"$directory:\$PATH\""
;;
esac
if [ "$setup" = true ]; then
for client in claude-code cursor codex; do
"$directory/proofline" agent install "$client" --yes ||
refuse "could not configure $client; earlier steps remain installed; fix the reported problem and rerun this command"
done
# init signs in, prints the GitHub App install address and waits for the
# installation, then prints the setup brief. On a host with no OS keychain
# it names the browser setup page instead; rerunning the installer there
# would fail the same way.
say "signing in to Proofline; approve the sign-in and install the GitHub App for your team"
status=0
"$directory/proofline" init || status=$?
case "$status" in
0) say "setup brief printed above; a coding agent can follow it from its shell now; restart the agent or reload MCP only to use Proofline's MCP tools" ;;
2) refuse "the GitHub App installation was not recorded in time; the CLI and MCP entries remain installed; install the App at the address printed above, then run '$directory/proofline init' to continue setup" ;;
3) refuse "CLI sign-in did not finish; the CLI and MCP entries remain installed; sign in as proofline's message above says, then run '$directory/proofline init' to continue setup" ;;
4) refuse "Proofline could not be reached; the CLI and MCP entries remain installed; run '$directory/proofline init' to continue setup" ;;
*) refuse "proofline init failed; the CLI and MCP entries remain installed; fix the reported problem and run '$directory/proofline init'" ;;
esac
else
say "run '$binary login' to sign in"
fi
}
main "$@"