Repository navigation
Expand file tree
/
Copy pathinstall.sh
More file actions
244 lines (223 loc) · 9.57 KB
/
Copy pathinstall.sh
File metadata and controls
244 lines (223 loc) · 9.57 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
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
#!/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.25.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
}
# Quote a path for the person or agent that copies the printed command.
shell_word() {
word=$1
printf "'"
while [ "${word#*\'}" != "$word" ]; do
printf "%s'\\\\''" "${word%%\'*}"
word=${word#*\'}
done
printf "%s'" "$word"
}
main() {
setup=false
case "${1:-}" in
--setup)
setup=true
shift
# Keep the optional target in "$@" for init. The public --setup has
# no arguments left after the shift.
case $# in
0) ;;
2 | 4)
if [ "$1" != --org ] || [ -z "$2" ]; then
refuse "--setup expects --org ID"
fi
if [ "$#" -eq 4 ]; then
if [ "$3" != --organization ] || [ -z "$4" ]; then
refuse "--org ID expects --organization github/LOGIN"
fi
fi
;;
*) refuse "--setup takes [--org ID [--organization github/LOGIN]]" ;;
esac
;;
--help)
[ "$#" -eq 1 ] || refuse "--help takes no arguments"
say "usage: curl -fsSL https://proofline.sh/cli | sh -s -- [--setup [--org ID [--organization github/LOGIN]]]"
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
;;
*) [ "$#" -eq 0 ] || 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
resolved=$(command -v proofline || :)
if [ "$resolved" != "$directory/proofline" ]; then
binary=$(shell_word "$directory/proofline")
case ":${PATH:-}:" in
*":$directory:"*)
path_issue="an earlier proofline shadows the installed CLI in this shell"
say "$resolved comes before the installed CLI on PATH; put the install directory first on PATH to use the downloaded proofline by name"
;;
*)
path_issue="proofline is not on PATH in this shell"
say "$directory is not on PATH; add it to run proofline by name"
;;
esac
# 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=$(shell_word "$directory"):\"\$PATH\""
fi
if [ "$setup" = true ]; then
# Setup from the shell needs no MCP entry, so an agent whose configuration
# proofline will not write is skipped rather than stopping sign-in.
skipped=
for client in claude-code cursor codex; do
if ! "$directory/proofline" agent install "$client" --yes; then
skipped="$skipped $client"
say "skipped $client; to add its MCP entry yourself, run '$binary agent install $client --print' and follow what it prints"
fi
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=$?
retry="$directory/proofline init${*:+ $*}"
case "$status" in
0)
if [ "$binary" = proofline ]; then
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"
else
say "setup brief printed above; $path_issue, so a coding agent must use $binary for the brief's commands or run the export PATH line printed above first; restart the agent or reload MCP only to use Proofline's MCP tools"
say "read setup status with this command."
say " $binary setup status"
fi
;;
2) say "the GitHub App installation was not recorded in time; the CLI and MCP entries remain installed; follow the install or approval instructions printed by init above, then run '$retry' to continue setup" ;;
3) say "CLI sign-in did not finish; the CLI and MCP entries remain installed; sign in as proofline's message above says, then run '$retry' to continue setup" ;;
4) say "Proofline could not be reached; the CLI and MCP entries remain installed; run '$retry' to continue setup" ;;
*) say "proofline init failed; the CLI and MCP entries remain installed; fix the reported problem and run '$retry'" ;;
esac
# The skipped agents are named last on every outcome, so nothing buries them.
[ -z "$skipped" ] ||
say "no MCP entry was written for:$skipped; see the reason above for each"
return "$status"
elif [ "$binary" = proofline ]; then
say "run '$binary init' to sign in and start setup; '$binary login' only signs in"
else
say "use this command to sign in and start setup."
say " $binary init"
say "$binary login only signs in"
fi
}
main "$@"