Repository navigation
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·1216 lines (1130 loc) · 54.8 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·1216 lines (1130 loc) · 54.8 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
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/bin/bash
# hashd installer
# Usage: curl -fsSL https://raw.githubusercontent.com/codr1/hashd-code/main/install.sh | bash
# Intended for packaged wheel installs/upgrades.
# This script should be safe to re-run; install, migration, and restart work
# are expected to be idempotent.
# Shared, read-only preflight for source and packaged installers.
# Resolve existing symlinks and missing trailing components without GNU readlink -f.
hashd_install_path() (
local path="$1" parent leaf target depth="${2:-0}"
case "$path" in *$'\n'*) echo 'Error: installation paths must not contain newlines.' >&2; return 1 ;; esac
[ "$depth" -lt 40 ] || return 1
case "$path" in /*) ;; *) path="$PWD/$path" ;; esac
[ "$path" != / ] || { printf '/\n'; return; }
path="${path%/}"
parent="$(dirname "$path")"
leaf="$(basename "$path")"
parent="$(hashd_install_path "$parent" "$((depth + 1))")" || return 1
case "$leaf" in
.) printf '%s\n' "$parent"; return ;;
..) dirname "$parent"; return ;;
esac
path="${parent%/}/$leaf"
if [ -L "$path" ]; then
target="$(readlink "$path")" || return 1
case "$target" in /*) ;; *) target="$parent/$target" ;; esac
hashd_install_path "$target" "$((depth + 1))"
else
printf '%s\n' "$path"
fi
)
# Old installs have no receipt. Recognize the same source/package layouts as
# the CLI bootstrap; an arbitrary executable or dangling link is not proof.
hashd_install_legacy_root() {
local launcher="$1" target="$1" root data dir link depth=0
# Source inference checks each launch location before following its symlink,
# including a cleaned checkout whose bin/hashd has not been rebuilt yet.
while [ "$depth" -lt 20 ]; do
dir="$(hashd_install_path "$(dirname "$target")")" || return 1
for root in "$(dirname "$dir")" "$dir"; do
if [ -f "$root/server/go.mod" ] &&
grep -Eq '^[[:space:]]*module github\.com/codr1/hashd/server[[:space:]]*$' "$root/server/go.mod"; then
printf '%s\n' "$root"
return
fi
done
[ -L "$target" ] || break
link="$(readlink "$target")" || return 1
case "$link" in /*) target="$link" ;; *) target="$dir/$link" ;; esac
depth=$((depth + 1))
done
target="$(hashd_install_path "$launcher")" || return 1
[ -f "$target" ] || return 1
root="$(dirname "$(dirname "$target")")"
for data in "$root"/lib/python*/site-packages/hashd_data \
"$root"/lib64/python*/site-packages/hashd_data "$root"/Lib/site-packages/hashd_data; do
if [ -d "$data/prompts" ] && [ -d "$data/templates" ] && [ -d "$data/schemas" ]; then
hashd_install_path "$HOME/.hashd"
return
fi
done
return 1
}
hashd_install_receipt_root() {
local launcher="$1" receipt version target root extra resolved
receipt="$(dirname "$launcher")/.hashd-install"
[ -e "$receipt" ] || [ -L "$receipt" ] || return 1
[ -f "$receipt" ] && [ ! -L "$receipt" ] || return 2
{
IFS= read -r version && IFS= read -r target && IFS= read -r root &&
! IFS= read -r extra && [ -z "$extra" ]
} < "$receipt" || return 2
[ "$version" = hashd-install-v1 ] || return 2
case "$root" in /*) ;; *) return 2 ;; esac
resolved="$(hashd_install_path "$launcher")" || return 2
[ "$target" = "$resolved" ] || return 1
hashd_install_path "$root" || return 2
}
# With no override, retain a recorded custom root on an ordinary update. A
# different source checkout still proposes its own root and requires consent.
hashd_install_default_root() {
local preferred="$1" default="$2" launcher legacy recorded
while IFS= read -r launcher; do
legacy="$(hashd_install_legacy_root "$launcher")" || legacy=""
if [ "$legacy" = "$default" ] && recorded="$(hashd_install_receipt_root "$launcher")"; then
printf '%s\n' "$recorded"
return
fi
done < <(hashd_install_launchers "$preferred")
printf '%s\n' "$default"
}
hashd_install_check() {
local launcher="$1" proposed="$2" replacement="$3" proposed_binary="$4"
local target current rc
[ -e "$launcher" ] || [ -L "$launcher" ] || return 0
target="$(hashd_install_path "$launcher")" || target="unresolved: $launcher"
if current="$(hashd_install_receipt_root "$launcher")"; then
:
else
rc=$?
if [ "$rc" = 1 ]; then
current="$(hashd_install_legacy_root "$launcher")" || current=""
fi
[ -n "$current" ] || current="unknown (installation could not be identified)"
fi
[ "$current" != "$proposed" ] || return 0
{
if [ "$replacement" = 1 ]; then
printf 'Replacing a competing hashd installation (--replace-install).\n'
else
printf 'Error: another hashd installation is already configured.\n'
fi
printf '\n Existing command: %s\n Existing executable: %s\n Existing operations root: %s\n' "$launcher" "$target" "$current"
printf '\n Proposed executable: %s\n Proposed operations root: %s\n\n' "$proposed_binary" "$proposed"
printf '%s\n' \
'Continuing would replace the installation used by the hashd command' \
'and restart services against the proposed installation.' \
'Existing data is not deleted or moved. Its projects, settings and' \
'authentication do not carry over automatically. A fresh installation' \
'uses solo mode; do not assume the existing team-mode authentication remains.'
if [ "$replacement" != 1 ]; then
printf '\n%s\n' \
'No installation changes have been made.' \
'To update normally, use the existing installation and operations root.' \
'To explicitly replace it, rerun this installer with --replace-install.'
fi
} >&2
[ "$replacement" = 1 ]
}
# Check every launcher the installers may replace, plus the active PATH entry.
# Nothing here executes the old binary, touches its data, or contacts services.
hashd_install_launchers() {
local launcher seen=$'\n'
for launcher in "${1:-}" "$HOME/.local/bin/hashd" "${PIPX_BIN_DIR:-$HOME/.local/bin}/hashd" \
"${UV_TOOL_BIN_DIR:-$HOME/.local/bin}/hashd" "$(type -P hashd || true)"; do
[ -n "$launcher" ] || continue
case "$seen" in *$'\n'"$launcher"$'\n'*) continue ;; esac
seen+="$launcher"$'\n'
printf '%s\n' "$launcher"
done
}
hashd_install_preflight() {
local proposed="$1" replacement="$2" proposed_binary="$3" launcher
proposed="$(hashd_install_path "$proposed")" || {
echo 'Error: cannot resolve the proposed operations root; no installation changes made.' >&2
return 1
}
while IFS= read -r launcher; do
hashd_install_check "$launcher" "$proposed" "$replacement" "$proposed_binary" || return 1
done < <(hashd_install_launchers)
}
# Bind the selected root to the installed executable, not to a release version.
# A receipt from a replaced launcher cannot authorize an unrelated installation.
hashd_install_record() (
local launcher="$1" root="$2" target receipt staged
target="$(hashd_install_path "$launcher")" || return 1
root="$(hashd_install_path "$root")" || return 1
case "$target$root" in *$'\n'*) echo 'Error: installation paths must not contain newlines.' >&2; return 1 ;; esac
receipt="$(dirname "$launcher")/.hashd-install"
[ ! -d "$receipt" ] || { echo "Error: $receipt is a directory, not an installation receipt." >&2; return 1; }
staged="$(mktemp "${receipt}.XXXXXX")" || return 1
trap 'rm -f "$staged"' EXIT
printf 'hashd-install-v1\n%s\n%s\n' "$target" "$root" > "$staged" || return 1
mv -f "$staged" "$receipt"
)
REPO="codr1/hashd-code"
COMPLETION_MARKER="# hashd/wf completions (managed by hashd install scripts -- drop after v1.0 once everyone has migrated)"
# --- Output: restrained color + step markers ---
#
# Quiet by default: one line per real step. Color is used sparingly and only
# when stdout is a TTY and NO_COLOR is unset (https://no-color.org). Errors
# render in the same error:/-->/Suggestions: shape as server/internal/diagnostic
# so the installer and `hashd doctor` speak with one voice.
if [ -t 1 ] && [ -z "${NO_COLOR:-}" ]; then
C_GREEN=$'\033[32m'
C_BLUE=$'\033[34m'
C_DIM=$'\033[2m'
C_BOLD=$'\033[1m'
C_RED=$'\033[31m'
C_RESET=$'\033[0m'
else
C_GREEN=""
C_BLUE=""
C_DIM=""
C_BOLD=""
C_RED=""
C_RESET=""
fi
# step: announce the start of a real step ("-> doing the thing").
step() {
printf '%s->%s %s\n' "$C_BLUE" "$C_RESET" "$1"
}
# ok: confirm a step finished (" + result"), optionally with dim detail.
ok() {
if [ -n "${2:-}" ]; then
printf ' %s+%s %s %s%s%s\n' "$C_GREEN" "$C_RESET" "$1" "$C_DIM" "$2" "$C_RESET"
else
printf ' %s+%s %s\n' "$C_GREEN" "$C_RESET" "$1"
fi
}
# verified: surface the SHA-256 check the installer already performs.
verified() {
printf ' %s+%s %s %sverified%s\n' "$C_GREEN" "$C_RESET" "$1" "$C_DIM" "$C_RESET"
}
# note: dim, secondary information.
note() {
printf ' %s%s%s\n' "$C_DIM" "$1" "$C_RESET"
}
# die: render a structured diagnostic and exit non-zero.
#
# Usage: die "<title>" "<source>" "<explanation>" "<help line>" ["<help line>" ...]
# The explanation may contain literal "\n" for multi-line context. Help lines
# render as a "Suggestions:" bullet list -- give the ONE OS-correct fix command,
# not a multi-platform menu.
die() {
local title="$1" source="$2" explanation="$3"
shift 3
printf '%serror:%s %s\n' "${C_RED}${C_BOLD}" "$C_RESET" "$title" >&2
if [ -n "$source" ]; then
printf ' --> %s\n' "$source" >&2
fi
if [ -n "$explanation" ]; then
printf '\n' >&2
printf '%b\n' "$explanation" | while IFS= read -r line; do
printf ' %s\n' "$line" >&2
done
fi
if [ "$#" -gt 0 ]; then
printf '\nSuggestions:\n' >&2
local hint
for hint in "$@"; do
printf ' - %s\n' "$hint" >&2
done
fi
exit 1
}
# --- uv bootstrap ---
#
# The Python -> pip -> pipx -> PEP-668 gauntlet hard-errors on a fresh modern
# box (Arch, Homebrew Python) where the system interpreter is
# externally-managed. uv sidesteps all of it: a single curl install with zero
# prereqs that can both provide a Python 3.11+ runtime and install the wheels
# via its pipx-equivalent (`uv tool install` + `--with` injected wheels).
UV_BIN=""
# uv_path: locate uv, preferring an already-on-PATH copy, then the standard
# installer location. Echoes the resolved path; returns non-zero if absent.
uv_path() {
if command -v uv &>/dev/null; then
command -v uv
return 0
fi
if [ -x "$HOME/.local/bin/uv" ]; then
echo "$HOME/.local/bin/uv"
return 0
fi
return 1
}
# python_pipx_healthy: true when a usable Python 3.11+ AND a working pipx are
# both present. This is the "healthy existing toolchain" fast path -- when it
# holds, we keep using pipx exactly as before and never touch uv.
python_pipx_healthy() {
[ -n "$PYTHON" ] || return 1
command -v pipx &>/dev/null || return 1
return 0
}
# pip_pipx_install_blocked: probe whether `pip install --user pipx` is viable.
# Returns 0 (blocked) when pip is missing or refuses with PEP-668
# "externally-managed-environment", which is the default on modern Arch and
# Homebrew Python. Returns 1 (not blocked) when pip can install user packages.
# Does not actually install -- uses a dry-run probe so the real install path
# stays a single code path.
pip_pipx_install_blocked() {
[ -n "$PYTHON" ] || return 0
if ! "$PYTHON" -m pip --version &>/dev/null; then
return 0
fi
local probe
probe="$("$PYTHON" -m pip install --user --dry-run pipx 2>&1)" || {
case "$probe" in
*externally-managed-environment*|*externally\ managed*)
return 0
;;
esac
# Some pip versions reject --dry-run; fall back to treating a generic
# failure as "not blocked" so the real attempt can decide.
case "$probe" in
*"no such option"*|*"unrecognized arguments"*)
return 1
;;
esac
return 0
}
return 1
}
# bootstrap_uv: ensure uv is installed, curl-bootstrapping it if missing.
# Sets UV_BIN to the resolved path. uv's installer needs no Python and no root.
bootstrap_uv() {
if UV_BIN="$(uv_path)"; then
ok "uv" "$("$UV_BIN" --version 2>/dev/null | extract_semver || echo present)"
return 0
fi
step "Installing uv (provides Python 3.11+, no prerequisites)"
if ! curl -fsSL https://astral.sh/uv/install.sh | sh >/dev/null 2>&1; then
die "Could not install uv" \
"install.uv_bootstrap" \
"uv is hashd's zero-prerequisite path to a Python 3.11+ runtime, and the curl bootstrap from https://astral.sh failed.\nThis usually means no network access or a proxy blocking astral.sh." \
"Install uv manually: https://docs.astral.sh/uv/getting-started/installation/" \
"Then re-run: curl -fsSL https://raw.githubusercontent.com/$REPO/main/install.sh | bash"
fi
export PATH="$HOME/.local/bin:$PATH"
if ! UV_BIN="$(uv_path)"; then
die "uv installed but not found on PATH" \
"install.uv_bootstrap" \
"The uv installer ran but uv is not on PATH at \$HOME/.local/bin/uv." \
"Open a new shell or run: export PATH=\"\$HOME/.local/bin:\$PATH\"" \
"Then re-run: curl -fsSL https://raw.githubusercontent.com/$REPO/main/install.sh | bash"
fi
ok "uv installed" "$("$UV_BIN" --version 2>/dev/null | extract_semver || echo present)"
}
# install_via_uv: install hashd + all extra wheels through uv's pipx-equivalent.
# `uv tool install` makes the primary wheel's entry points (hashd, wf, ha,
# hashd-server)
# available on PATH; `--with` injects the bot/connector/tui wheels into the same
# managed environment. uv provides a Python 3.11+ interpreter itself, so this
# works even when the host has no system Python.
install_via_uv() {
HASHD_BIN="${UV_TOOL_BIN_DIR:-$HOME/.local/bin}/hashd"
step "Installing hashd via uv (Python 3.11+ managed by uv)"
"$UV_BIN" tool install --force --python 3.11 \
--with "$CLIENT_WHEEL" \
--with "$BOT_WHEEL" \
--with "$FIGMA_WHEEL" \
--with "$GITHUB_CONNECTOR_WHEEL" \
--with "$JIRA_WHEEL" \
--with "$CONFLUENCE_WHEEL" \
--with "$AZURE_WHEEL" \
--with "$CLICKUP_WHEEL" \
--with "$TUI_WHEEL" \
"$WHEEL"
# uv tool installs land in ~/.local/bin by default; make sure it's wired up.
"$UV_BIN" tool update-shell >/dev/null 2>&1 || true
export PATH="$HOME/.local/bin:$PATH"
}
# install_via_pipx: the classic healthy-toolchain path. Unchanged behavior:
# pipx owns the primary wheel, runpip injects the extras.
install_via_pipx() {
HASHD_BIN="${PIPX_BIN_DIR:-$HOME/.local/bin}/hashd"
step "Installing hashd via pipx"
pipx install --force --pip-args "--find-links $WORK_DIR" "$WHEEL" 2>&1 | grep -v "^$" | grep -v '[✨🌟⚠️]'
pipx runpip hashd install --upgrade "$CLIENT_WHEEL" 2>&1 | grep -v "^$" | grep -v '[✨🌟⚠️]'
pipx runpip hashd install --upgrade "$BOT_WHEEL" 2>&1 | grep -v "^$" | grep -v '[✨🌟⚠️]'
pipx runpip hashd install --upgrade "$FIGMA_WHEEL" 2>&1 | grep -v "^$" | grep -v '[✨🌟⚠️]'
pipx runpip hashd install --upgrade "$GITHUB_CONNECTOR_WHEEL" 2>&1 | grep -v "^$" | grep -v '[✨🌟⚠️]'
pipx runpip hashd install --upgrade "$JIRA_WHEEL" 2>&1 | grep -v "^$" | grep -v '[✨🌟⚠️]'
pipx runpip hashd install --upgrade "$CONFLUENCE_WHEEL" 2>&1 | grep -v "^$" | grep -v '[✨🌟⚠️]'
pipx runpip hashd install --upgrade "$AZURE_WHEEL" 2>&1 | grep -v "^$" | grep -v '[✨🌟⚠️]'
pipx runpip hashd install --upgrade "$CLICKUP_WHEEL" 2>&1 | grep -v "^$" | grep -v '[✨🌟⚠️]'
pipx runpip hashd install --upgrade "$TUI_WHEEL" 2>&1 | grep -v "^$" | grep -v '[✨🌟⚠️]'
pipx ensurepath 2>/dev/null || true
}
# node_install_hint: the ONE OS-correct command to install a Node.js runtime,
# used in the agent on-ramp printed at finish. Agents are npm-installed, so Node
# is the agent's prerequisite -- not hashd's.
node_install_hint() {
if [ "$PLATFORM" = "macosx" ]; then
echo "brew install node"
else
echo "https://github.com/nvm-sh/nvm then: nvm install 20"
fi
}
# git_install_hint: the ONE OS-correct command to install git. git is a system
# prerequisite hashd shells out to for every project op (worktrees, commits,
# merges) -- the installer checks for it but, like a C library or coreutils,
# never bundles or installs it. Detect the platform's package manager so the
# suggestion is a single copy-paste line, not a multi-distro menu.
git_install_hint() {
if [ "$PLATFORM" = "macosx" ]; then
echo "xcode-select --install"
elif command -v apt-get &>/dev/null; then
echo "sudo apt-get install -y git"
elif command -v dnf &>/dev/null; then
echo "sudo dnf install -y git"
elif command -v pacman &>/dev/null; then
echo "sudo pacman -S --noconfirm git"
elif command -v zypper &>/dev/null; then
echo "sudo zypper install -y git"
elif command -v apk &>/dev/null; then
echo "sudo apk add git"
else
echo "install git with your system package manager"
fi
}
# rc_targets: the shell rc files the installer manages (PATH + completions).
# Always ~/.bashrc (bash). macOS Terminal runs zsh and never sources ~/.bashrc,
# so include ~/.zshrc on macOS -- and on Linux too when the login shell is zsh.
# Without this the freshly installed hashd/wf entry points and the bundled tools
# never land on the zsh PATH, and `hashd`/`wf` read as command-not-found.
# rc_targets: every file that should carry the PATH snippet.
#
# ~/.bashrc covers interactive shells, and most distro bashrc files return
# early for non-interactive ones -- so a plain `ssh host 'hashd ...'` sees
# none of it. ~/.profile / ~/.zprofile cover LOGIN shells, which is what
# `ssh host bash -lc '...'` and desktop sessions get. Between them the
# remaining gap is a non-login non-interactive shell, which no file can
# reach portably; the closing note tells the operator what to do there
# instead of pretending it is covered.
# bash_login_profile names the file a login bash actually reads: the first
# existing of ~/.bash_profile, ~/.bash_login, ~/.profile -- bash consults one
# and stops. Writing ~/.profile unconditionally misses any box that has a
# ~/.bash_profile which does not source it.
bash_login_profile() {
for candidate in "$HOME/.bash_profile" "$HOME/.bash_login" "$HOME/.profile"; do
if [ -f "$candidate" ]; then
printf '%s\n' "$candidate"
return
fi
done
printf '%s\n' "$HOME/.profile"
}
rc_targets() {
printf '%s\n' "$HOME/.bashrc"
printf '%s\n' "$(bash_login_profile)"
case "${SHELL:-}" in
*zsh*) printf '%s\n' "$HOME/.zshrc"; printf '%s\n' "$HOME/.zprofile"; return ;;
esac
if [ "${PLATFORM:-}" = "macosx" ]; then
printf '%s\n' "$HOME/.zshrc"
printf '%s\n' "$HOME/.zprofile"
fi
}
# ensure_dir_on_path: put DIR on PATH for the rest of this run and persist it
# into every rc_targets file, keyed by MARKER so re-runs don't duplicate. Used
# for the entry-points dir (~/.local/bin -- uv/pipx wire it for bash but not
# reliably for zsh) and the bundled-tools dir (~/.hashd/tools/bin).
ensure_dir_on_path() {
local dir="$1" marker="$2" rc
mkdir -p "$dir"
# Make it effective for the rest of this install run too.
case ":$PATH:" in
*":$dir:"*) ;;
*) export PATH="$dir:$PATH" ;;
esac
while IFS= read -r rc; do
mkdir -p "$(dirname "$rc")"
touch "$rc"
if grep -qF "$marker" "$rc"; then
continue
fi
if [[ -s "$rc" ]]; then
printf '\n' >> "$rc"
fi
# Guarded rather than a bare export: the snippet now lives in both
# an rc and a profile, and an interactive login shell sources both.
printf '%s\ncase ":$PATH:" in *":%s:"*) ;; *) export PATH="%s:$PATH" ;; esac\n' \
"$marker" "$dir" "$dir" >> "$rc"
done < <(rc_targets)
}
# ensure_tools_dir_on_path: persist the bundled-tools dir (~/.hashd/tools/bin,
# honoring $HASHD_TOOLS_DIR) onto PATH. install-tools.sh drops gitleaks,
# git-delta and ripgrep there; without this they resolve for hashd's tools-dir-aware code
# but not as bare `gitleaks`/`delta` on the user's own PATH.
ensure_tools_dir_on_path() {
ensure_dir_on_path "${HASHD_TOOLS_DIR:-$HOME/.hashd/tools/bin}" \
"# hashd tools dir (managed by hashd install scripts)"
}
# install_completions: wire shell completions into each rc_targets file, per
# shell -- bash rc gets `completion bash`, zsh rc gets `completion zsh` (which
# cobra emits as a compdef script, so it needs compinit first). Idempotent: the
# prior managed block and any legacy hand-written wf-completion lines are
# stripped before the current block is appended, so re-runs don't stack.
# Each source line is guarded by `command -v` so a login shell never errors when
# the binary is transiently absent (mid-upgrade, cleaned build, moved checkout):
# the completion is skipped, not shouted about on every prompt.
install_completions() {
local rc tmp block
while IFS= read -r rc; do
mkdir -p "$(dirname "$rc")"
touch "$rc"
tmp="$(mktemp)"
# Strip the prior managed block + any legacy hashd/wf completion lines.
# Use grep, not awk: minimal images ship coreutils (grep) but not always
# gawk. grep -v exits 1 when every line is filtered out, which is not an
# error here, so guard with `|| true`.
grep -vE \
-e '^[[:space:]]*# hashd/wf shell completions[[:space:]]*$' \
-e '^[[:space:]]*# hashd/wf completions \(managed by .* drop after v1\.0 once everyone has migrated\)[[:space:]]*$' \
-e '^[[:space:]]*source[[:space:]]+["]?[^"]*wf-completion\.bash["]?[[:space:]]*$' \
-e '^[[:space:]]*\[\[[^]]*wf-completion\.bash[^]]*\]\][[:space:]]*&&[[:space:]]*source[[:space:]]+["]?[^"]*wf-completion\.bash["]?[[:space:]]*$' \
-e '^[[:space:]]*autoload -Uz compinit && compinit -u[[:space:]]*$' \
-e '^[[:space:]]*source[[:space:]]+<\((hashd|wf|ha) completion (bash|zsh)\)[[:space:]]*$' \
-e '^[[:space:]]*command -v (hashd|wf|ha) >/dev/null 2>&1 && source[[:space:]]+<\((hashd|wf|ha) completion (bash|zsh)\)[[:space:]]*$' \
"$rc" > "$tmp" || true
mv "$tmp" "$rc"
if [[ -s "$rc" ]]; then
printf '\n' >> "$rc"
fi
case "$rc" in
*.zshrc)
# cobra's zsh completion is a compdef script; compinit must have
# run for it to register. compinit is safe to re-run (-u skips
# the insecure-directory prompt in a non-interactive rc).
block=$'autoload -Uz compinit && compinit -u\ncommand -v hashd >/dev/null 2>&1 && source <(hashd completion zsh)\ncommand -v wf >/dev/null 2>&1 && source <(wf completion zsh)\ncommand -v ha >/dev/null 2>&1 && source <(ha completion zsh)'
;;
*)
block=$'command -v hashd >/dev/null 2>&1 && source <(hashd completion bash)\ncommand -v wf >/dev/null 2>&1 && source <(wf completion bash)\ncommand -v ha >/dev/null 2>&1 && source <(ha completion bash)'
;;
esac
printf '%s\n%s\n' "$COMPLETION_MARKER" "$block" >> "$rc"
done < <(rc_targets)
}
promote_pipx_binary() {
local name="$1"
local bin_dir="${PIPX_BIN_DIR:-$HOME/.local/bin}"
local pipx_home="${PIPX_HOME:-$HOME/.local/pipx}"
local target="${bin_dir}/${name}"
local source="${pipx_home}/venvs/hashd/bin/${name}"
if [ -x "$target" ]; then
return 0
fi
if [ ! -x "$source" ]; then
return 1
fi
mkdir -p "$bin_dir"
ln -sf "$source" "$target"
}
extract_first_major_minor() {
sed -nE 's/[^0-9]*([0-9]+\.[0-9]+).*/\1/p' | head -1
}
# Print the first semver in the input. Anchored to the FIRST match, not the
# last: tools print their own version first and may append build metadata that
# is itself a semver -- e.g. `tea --version` emits
# "Version: 0.14.1 golang: 1.26.3 go-sdk: v0.25.1", and a greedy last-match
# would wrongly read the go-sdk version as the tool version.
extract_semver() {
grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | head -1
}
warn_external_tools() {
echo "WARN: external tool install skipped ($1)."
echo " This step vendors gitleaks, git-delta, ripgrep, and the forge CLIs (gh, glab, bkt, tea)."
echo " Without them: the merge secret-scan and your forge's features will not work."
echo " Fix: re-run this installer once the fetch succeeds."
}
# remote_server_paired: true when HASHD_SERVER_URL names a non-loopback server.
# Such a client has no local server to own and runs no agents, so it gets
# neither a local owner nor the browser runtime. install-tools.sh repeats this
# test because it is fetched standalone and cannot source this file.
remote_server_paired() {
[ -n "${HASHD_SERVER_URL:-}" ] && ! printf '%s' "$HASHD_SERVER_URL" | grep -qE '://(127\.0\.0\.1|localhost|\[::1\])'
}
# install.sh's exit status when the browser runtime was wanted and this run
# could not install it. die and usage exit 1, and set -e passes on the hashd
# CLI's own statuses (1, 2, 6, 10, 130, 253), so a script can tell this outcome
# apart.
BROWSER_MISSING_EXIT=75
# The browser install outcome record install-tools.sh writes into its tools
# dir (BROWSER_INSTALL_STATUS there; `hashd doctor` reads it). Named here
# rather than by sourcing install-tools.sh: it is fetched standalone and its
# entry point runs when sourced.
BROWSER_INSTALL_STATUS=".browser-install-status"
# browser_install_record: the outcome record's path.
browser_install_record() {
printf '%s/%s\n' "${HASHD_TOOLS_DIR:-$HOME/.hashd/tools/bin}" "$BROWSER_INSTALL_STATUS"
}
# record_browser_install_failure <reason> records a failure that kept
# install-tools.sh from running, for `hashd doctor`. Twin of install-tools.sh's
# write_browser_install_status, which is not available when its script could
# not be downloaded; TestInstallSHBrowserRuntimeOutcome reads the result back
# through doctor's reader. The record is replaced in one rename.
record_browser_install_failure() {
local file staged
file="$(browser_install_record)"
if ! mkdir -p "$(dirname "$file")" || ! staged="$(mktemp "$file.XXXXXX")"; then
echo "WARN: could not record the browser install outcome in $file; hashd doctor will not show it."
return 0
fi
if ! printf 'outcome=failed\nreason=%s\n' "$1" >"$staged" || ! chmod 644 "$staged" || ! mv -f "$staged" "$file"; then
rm -f "$staged"
echo "WARN: could not record the browser install outcome in $file; hashd doctor will not show it."
fi
}
# browser_install_status <file> <key> prints the recorded value of key, nothing
# when the key is absent. Same format as install-tools.sh's
# read_browser_install_status: one key=value per line.
browser_install_status() {
local line
while IFS= read -r line; do
case "$line" in
"$2="*) printf '%s\n' "${line#"$2="}"; return 0 ;;
esac
done <"$1"
}
# install_external_tools <base url> <os> <arch>: fetch the selected release's
# install-tools.sh and browser lock files into $WORK_DIR and run it. Under
# --without-browser (WITHOUT_BROWSER=1) the lock files are not fetched and
# install-tools.sh is told to skip the browser leg. A fetch failure that keeps
# the browser from installing is kept in BROWSER_INSTALL_FAILURE; one that keeps
# install-tools.sh from running is recorded for doctor too. install-tools.sh
# copies this run's outcome to BROWSER_INSTALL_RESULT, private to this run:
# concurrent installers share the tools dir's record, so it may be another's.
install_external_tools() {
local base_url="$1" tools_os="$2" tools_arch="$3" browser_lock cbm_bin_dir
local tools_args=()
BROWSER_INSTALL_FAILURE= BROWSER_INSTALL_RESULT="$WORK_DIR/browser-install-result"
mkdir -p "$WORK_DIR/scripts" "$WORK_DIR/vendor/playwright"
if ! curl --fail --silent --location \
--retry 3 --retry-delay 2 \
--connect-timeout 10 --max-time 60 \
"$base_url/scripts/install-tools.sh" -o "$WORK_DIR/scripts/install-tools.sh" 2>/dev/null; then
BROWSER_INSTALL_FAILURE="install-tools.sh could not be downloaded from $base_url/scripts/install-tools.sh"
warn_external_tools "could not download installer script"
if [ "${WITHOUT_BROWSER:-0}" != 1 ] && ! remote_server_paired; then
record_browser_install_failure "$BROWSER_INSTALL_FAILURE"
fi
die "Code tools could not be verified" "install.cbm" \
"$BROWSER_INSTALL_FAILURE" "Re-run the hashd installer after restoring access to the release."
fi
if ! curl -fsSL --retry 3 --connect-timeout 10 --max-time 60 \
"$base_url/vendor/cbm.lock" -o "$WORK_DIR/vendor/cbm.lock"; then
die "Code tools could not be verified" "install.cbm" \
"The release's vendor/cbm.lock could not be downloaded." "Re-run the hashd installer after restoring access to the release."
fi
# The wheel already carries CBM beside hashd. Verify/repair that copy,
# without downloading a second binary into the shared tools directory.
cbm_bin_dir="$(dirname "$(hashd_install_path "$HASHD_BIN")")"
# v0.9.29's tagged lock pins a glibc-2.38 Linux build. Remove this repair
# when installs/upgrades from that published release are no longer supported.
if [ "$tools_os" = linux ]; then
PATH="$cbm_bin_dir:$PATH" python3 - "$WORK_DIR/vendor/cbm.lock" <<'PY'
import json
import sys
from pathlib import Path
path = Path(sys.argv[1])
lock = json.loads(path.read_text(encoding="utf-8"))
if lock.get("version") == "v0.8.1":
hashes = {
"linux-amd64": (
"dbd3b92ea870ef240b63059f26bda15015f76ef9978931bebc3a0f9d09470973",
"6ab87a6c05d049dde57700803ca0ab4199fcf25973a0606618af0fcee73f5abd",
),
"linux-arm64": (
"d2f842d1365da5c35d9c5796f57a821c9745267350994346735e1e6e04d46091",
"13526acc2a6a0697dff3c763fb443a416589bc10ad8b12015b63d87e515dd72b",
),
}
changed = False
for platform, (regular_sha, portable_sha) in hashes.items():
url = f"https://github.com/codr1/codebase-memory-mcp/releases/download/v0.8.1/codebase-memory-mcp-{platform}"
entry = lock.get("platforms", {}).get(platform)
if entry == {"url": f"{url}.tar.gz", "sha256": regular_sha}:
entry.update(url=f"{url}-portable.tar.gz", sha256=portable_sha)
changed = True
if changed:
path.write_text(json.dumps(lock, indent=2, sort_keys=True) + "\n", encoding="utf-8")
PY
fi
# uv/pipx supply Python beside hashd; a bare host need not have python3.
if ! PATH="$cbm_bin_dir:$PATH" bash "$WORK_DIR/scripts/install-tools.sh" cbm --dest "$cbm_bin_dir/codebase-memory-mcp"; then
die "Code tools could not be installed" "install.cbm" \
"The pinned codebase-memory-mcp binary could not be installed and verified." "Resolve the installer failure above, then re-run the hashd installer."
fi
if [ "${WITHOUT_BROWSER:-0}" = 1 ]; then
tools_args=(--without-browser)
else
for browser_lock in package.json package-lock.json; do
if ! curl -fsSL --retry 3 --connect-timeout 10 --max-time 60 \
"$base_url/vendor/playwright/$browser_lock" \
-o "$WORK_DIR/vendor/playwright/$browser_lock"; then
BROWSER_INSTALL_FAILURE="${BROWSER_INSTALL_FAILURE:+$BROWSER_INSTALL_FAILURE; }the browser lock file $browser_lock could not be downloaded from $base_url/vendor/playwright/$browser_lock"
warn_external_tools "could not download browser lock $browser_lock; browser installation will report unavailable"
fi
done
fi
if ! PATH="$cbm_bin_dir:$PATH" HASHD_PACKAGE_BIN_DIR="$cbm_bin_dir" HASHD_BROWSER_INSTALL_RESULT="$BROWSER_INSTALL_RESULT" HASHD_TOOLS_OS="$tools_os" HASHD_TOOLS_ARCH="$tools_arch" bash "$WORK_DIR/scripts/install-tools.sh" "${tools_args[@]}"; then
warn_external_tools "installer script failed"
fi
}
# browser_runtime_outcome: print the installer's last line about the browser
# runtime, and return 0 or BROWSER_MISSING_EXIT. Prints nothing for a
# remote-paired client (it never gets the runtime) and for a successful
# install. Otherwise the outcome is what install_external_tools and this run's
# BROWSER_INSTALL_RESULT say happened, never install-tools.sh's exit status: a
# failure there need not be the browser's, and a browser failure does not fail
# it. A runtime still in place after a failed upgrade is the previous one,
# kept, and named; the install still failed, so the status is
# BROWSER_MISSING_EXIT.
browser_runtime_outcome() {
local runtime="${HASHD_TOOLS_DIR:-$HOME/.hashd/tools/bin}/playwright-cli" result="${BROWSER_INSTALL_RESULT:-}" reason
if remote_server_paired; then
return 0
fi
if [ "${WITHOUT_BROWSER:-0}" = 1 ]; then
if [ -x "$runtime" ]; then
printf "browser runtime: existing runtime kept at %s, not upgraded (skipped at the operator's request via --without-browser)\n" "$runtime"
else
printf "browser runtime: not installed (skipped at the operator's request via --without-browser); browser validation disabled\n"
fi
return 0
fi
reason="${BROWSER_INSTALL_FAILURE:-}"
if [ -n "$result" ] && [ -f "$result" ]; then
if [ "$(browser_install_status "$result" outcome)" = succeeded ]; then
return 0
fi
[ -n "$reason" ] || reason="$(browser_install_status "$result" reason)"
[ -n "$reason" ] || reason="the browser install failed without recording a reason"
elif [ -z "$reason" ]; then
reason="install-tools.sh did not reach the browser step (it recorded no browser install outcome during this run)"
fi
if [ -x "$runtime" ]; then
printf 'browser runtime: previous runtime kept at %s; the upgrade failed (%s)\n' "$runtime" "$reason"
else
printf 'browser runtime: not installed (%s); browser validation disabled\n' "$reason"
fi
return "$BROWSER_MISSING_EXIT"
}
# setup.sh and installer tests source definitions without running installation.
if [ -n "${BASH_SOURCE[0]:-}" ] && [ "${BASH_SOURCE[0]}" != "$0" ]; then
return 0
fi
set -e
REPLACE_INSTALL=0
WITHOUT_BROWSER=0
for arg in "$@"; do
case "$arg" in
--replace-install) REPLACE_INSTALL=1 ;;
--without-browser) WITHOUT_BROWSER=1 ;;
-y|--yes) ;; # Already non-interactive; never authorizes replacement.
*) echo "Usage: install.sh [--replace-install] [--without-browser]" >&2; exit 1 ;;
esac
done
# Refuse before dependency installation, downloads, migrations, or service changes.
OPS_ROOT="${HASHD_OPS_ROOT:-$(hashd_install_default_root '' "$(hashd_install_path "$HOME/.hashd")")}"
OPS_ROOT="$(hashd_install_path "$OPS_ROOT")"
export HASHD_OPS_ROOT="$OPS_ROOT"
hashd_install_preflight "$OPS_ROOT" "$REPLACE_INSTALL" 'packaged hashd (uv/pipx managed)'
# --- Detect platform ---
OS="$(uname -s)"
ARCH="$(uname -m)"
case "$OS" in
Linux) PLATFORM="linux" ;;
Darwin) PLATFORM="macosx" ;;
*)
echo "Unsupported OS: $OS"
exit 1
;;
esac
case "$ARCH" in
x86_64) MACHINE="x86_64" ;;
aarch64|arm64) MACHINE="aarch64" ;;
*)
echo "Unsupported architecture: $ARCH"
exit 1
;;
esac
printf '%shashd installer%s %s%s (%s)%s\n' "$C_BOLD" "$C_RESET" "$C_DIM" "$PLATFORM" "$MACHINE" "$C_RESET"
# --- Preflight: git is a hard prerequisite ---
#
# hashd shells out to the system git for every project op (worktrees, commits,
# merges). Unlike the specialty tools this installer vendors (gitleaks,
# git-delta, the forge CLIs), git is a base system dependency -- like a C
# library -- that hashd requires but never installs. Fail here, before any
# download or toolchain work, with the one command that fixes it.
if ! command -v git &>/dev/null; then
die "git is required but was not found on PATH" \
"install.preflight" \
"hashd drives every project through git -- creating worktrees, committing micro-commits, and merging -- by shelling out to your system git.\nIt is a base system prerequisite the installer checks for but does not provide." \
"Install git, then re-run this installer: $(git_install_hint)"
fi
# --- Resolve the Python toolchain ---
#
# Fast path: a healthy existing Python 3.11+ with a working pipx -> use pipx.
# Otherwise (no Python, or a modern externally-managed interpreter where
# `pip install --user pipx` would hit PEP-668) -> bootstrap uv, which provides
# both a Python 3.11+ runtime and the install mechanism. One curl, no root.
step "Resolving Python toolchain"
PYTHON=""
PYTHON_VERSION=""
for cmd in python3.14 python3.13 python3.12 python3.11 python3; do
if command -v "$cmd" &>/dev/null; then
version=$("$cmd" --version 2>&1 | extract_first_major_minor)
major=$(echo "$version" | cut -d. -f1)
minor=$(echo "$version" | cut -d. -f2)
if [ -n "$major" ] && [ -n "$minor" ] && { [ "$major" -gt 3 ] || { [ "$major" -eq 3 ] && [ "$minor" -ge 11 ]; }; }; then
PYTHON="$cmd"
PYTHON_VERSION="$version"
break
fi
fi
done
INSTALL_VIA=""
if python_pipx_healthy; then
INSTALL_VIA="pipx"
ok "Python $PYTHON_VERSION + pipx" "$PYTHON"
elif [ -n "$PYTHON" ] && command -v uv &>/dev/null; then
# Python present but pipx missing. uv is already here, so prefer it over
# the pip -> pipx -> PEP-668 gauntlet.
INSTALL_VIA="uv"
note "Python $PYTHON_VERSION found; pipx missing -- using uv"
bootstrap_uv
elif [ -n "$PYTHON" ] && ! pip_pipx_install_blocked; then
# Python present, pip can install user packages: bootstrap pipx the classic
# way and keep the healthy toolchain path.
note "Python $PYTHON_VERSION found; installing pipx"
if ! "$PYTHON" -m pip --version &>/dev/null; then
"$PYTHON" -m ensurepip --user 2>/dev/null || true
fi
if "$PYTHON" -m pip install --user pipx 2>/dev/null; then
export PATH="$HOME/.local/bin:$PATH"
pipx ensurepath 2>/dev/null || "$PYTHON" -m pipx ensurepath 2>/dev/null || true
INSTALL_VIA="pipx"
ok "pipx" "$(pipx --version 2>/dev/null || echo installed)"
else
# pip surprised us; fall back to uv rather than hard-error.
note "pip could not install pipx -- using uv"
INSTALL_VIA="uv"
bootstrap_uv
fi
else
# No usable Python, or a modern externally-managed interpreter that refuses
# `pip install --user`. This is the fresh-Arch / Homebrew-Python case the
# old installer hard-errored on. uv provides Python 3.11+ itself.
if [ -n "$PYTHON" ]; then
note "Python $PYTHON_VERSION is externally managed (PEP 668) -- using uv"
else
note "No Python 3.11+ found -- uv will provide one"
fi
INSTALL_VIA="uv"
bootstrap_uv
fi
WORK_DIR=$(mktemp -d)
trap 'rm -rf "$WORK_DIR"' EXIT
# --- Find latest release ---
step "Finding latest release"
# Resolve the latest tag WITHOUT api.github.com. github.com/<repo>/releases/latest
# is a web/CDN 302 redirect to /releases/tag/<tag> -- no 60/hr unauthenticated
# cap, the cap that broke fresh-box installs (no `gh` yet, so unauthenticated).
RELEASE_URL="$(curl -fsSL -o /dev/null -w '%{url_effective}' "https://github.com/$REPO/releases/latest" 2>/dev/null || true)"
RELEASE_TAG=""
case "$RELEASE_URL" in
*/releases/tag/*) RELEASE_TAG="${RELEASE_URL##*/releases/tag/}" ;;
esac
if [ -z "$RELEASE_TAG" ]; then
die "No hashd release found" \
"install.release_lookup" \
"Could not read the latest release from github.com/$REPO.\nThis usually means no network access or GitHub is unreachable." \
"Check connectivity, then re-run: curl -fsSL https://raw.githubusercontent.com/$REPO/main/install.sh | bash" \
"Or browse releases manually: https://github.com/$REPO/releases"
fi
ok "Latest release" "$RELEASE_TAG"
# --- Resolve wheel names (downloaded via direct release-asset CDN URLs) ---
# The core wheel is a pure-Python carrier for per-platform Go binaries:
# python tag py3-none, platform tag set explicitly by the release build
# (HASHD_WHEEL_PLAT). macOS ships an arm64 wheel (Apple Silicon; the Go
# binaries are single-arch). Names are constructed from the version +
# platform so downloads use direct CDN URLs (no GitHub API).
ABI_TAG="py3-none"
VERSION="${RELEASE_TAG#v}"
if [ "$PLATFORM" = "macosx" ]; then
WHEEL_PLATFORM="macosx_11_0_arm64"
else
WHEEL_PLATFORM="${PLATFORM}_${MACHINE}"
fi
WHEEL="hashd-${VERSION}-${ABI_TAG}-${WHEEL_PLATFORM}.whl"
BOT_WHEEL="hashd_bot_telegram-${VERSION}-py3-none-any.whl"
FIGMA_WHEEL="hashd_connector_figma-${VERSION}-py3-none-any.whl"
GITHUB_CONNECTOR_WHEEL="hashd_connector_github-${VERSION}-py3-none-any.whl"
JIRA_WHEEL="hashd_connector_jira-${VERSION}-py3-none-any.whl"
CONFLUENCE_WHEEL="hashd_connector_confluence-${VERSION}-py3-none-any.whl"
AZURE_WHEEL="hashd_connector_azure_devops-${VERSION}-py3-none-any.whl"
CLICKUP_WHEEL="hashd_connector_clickup-${VERSION}-py3-none-any.whl"
TUI_WHEEL="hashd_tui-${VERSION}-py3-none-any.whl"
CLIENT_WHEEL="hashd_client-${VERSION}-py3-none-any.whl"
# Download via direct release-asset CDN URLs -- no api.github.com, so immune to
# the unauthenticated 60/hr limit that fresh boxes (no `gh` yet) used to hit.
#
# An interactive terminal gets a per-wheel progress bar -- the hashd wheel is
# ~170MB and otherwise downloads in total silence (looks hung). A non-TTY run
# (CI / piped logs) stays quiet but still surfaces curl's error (-sS). --retry
# absorbs a transient CDN blip on any single wheel; without it one failed fetch
# aborts the whole install. No --max-time: the hashd wheel is large and must not
# be cut off mid-download.
step "Downloading wheels"
if [ -t 2 ]; then
_curl_dl=(--progress-bar)
else
_curl_dl=(-sS)
fi
DL_BASE="https://github.com/$REPO/releases/download/$RELEASE_TAG"
for _wheel in "$WHEEL" "$CLIENT_WHEEL" "$BOT_WHEEL" "$FIGMA_WHEEL" "$GITHUB_CONNECTOR_WHEEL" "$JIRA_WHEEL" "$CONFLUENCE_WHEEL" "$AZURE_WHEEL" "$CLICKUP_WHEEL" "$TUI_WHEEL"; do
printf ' %s\n' "$_wheel"
if ! curl -fL --connect-timeout 20 --retry 3 --retry-delay 2 \
"${_curl_dl[@]}" -o "$WORK_DIR/$_wheel" "$DL_BASE/$_wheel"; then
die "Could not download $_wheel" \
"install.wheel_download" \
"Failed to download $_wheel from the $RELEASE_TAG release.\nThis is a direct CDN download (no GitHub API), so it usually means no network access, or no wheel was published for this platform ($PLATFORM/$MACHINE)." \
"Check the release assets: https://github.com/$REPO/releases/tag/$RELEASE_TAG" \
"Then re-run: curl -fsSL https://raw.githubusercontent.com/$REPO/main/install.sh | bash"
fi
done
# Resolve to absolute paths for the install step (the loop verified each download).
WHEEL="$WORK_DIR/$WHEEL"
BOT_WHEEL="$WORK_DIR/$BOT_WHEEL"
FIGMA_WHEEL="$WORK_DIR/$FIGMA_WHEEL"
GITHUB_CONNECTOR_WHEEL="$WORK_DIR/$GITHUB_CONNECTOR_WHEEL"
JIRA_WHEEL="$WORK_DIR/$JIRA_WHEEL"
CONFLUENCE_WHEEL="$WORK_DIR/$CONFLUENCE_WHEEL"
AZURE_WHEEL="$WORK_DIR/$AZURE_WHEEL"
CLICKUP_WHEEL="$WORK_DIR/$CLICKUP_WHEEL"
TUI_WHEEL="$WORK_DIR/$TUI_WHEEL"
CLIENT_WHEEL="$WORK_DIR/$CLIENT_WHEEL"
ok "Downloaded wheels" "CLI + server + client SDK + bot + figma/github/jira/confluence/azure/clickup connectors + TUI"
# Forge CLIs (gh, glab, bkt, tea) are installed further down by
# scripts/install-tools.sh, which owns every vendored tool and its pin.
# Nothing between here and there needs one.
# --- Install hashd wheels ---
# Either pipx (healthy existing toolchain) or uv (provides Python 3.11+ and the
# install mechanism on a bare box). Both land entry points in ~/.local/bin.
if [ "$INSTALL_VIA" = "uv" ]; then
install_via_uv
else
install_via_pipx
fi
ok "hashd installed"
mkdir -p "$OPS_ROOT"/{projects,workstreams,worktrees,runs,locks,cache,secrets,config}
if [ "$INSTALL_VIA" = "pipx" ]; then
promote_pipx_binary hashd || true