-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·2421 lines (2145 loc) · 82.9 KB
/
install.sh
File metadata and controls
executable file
·2421 lines (2145 loc) · 82.9 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
set -euo pipefail
# OpenRappter Installer for macOS and Linux
# Usage: curl -fsSL https://kody-w.github.io/openrappter/install.sh | bash
# Prevent sharp from trying to download global libvips (causes build failures in CI/Docker)
export SHARP_IGNORE_GLOBAL_LIBVIPS=1
BOLD='\033[1m'
ACCENT='\033[38;2;16;185;129m' # green-bright #10b981
# shellcheck disable=SC2034
ACCENT_BRIGHT='\033[38;2;52;211;153m' # lighter green #34d399
INFO='\033[38;2;136;146;176m' # text-secondary #8892b0
SUCCESS='\033[38;2;0;229;204m' # cyan-bright #00e5cc
WARN='\033[38;2;255;176;32m' # amber
ERROR='\033[38;2;230;57;70m' # coral-mid #e63946
MUTED='\033[38;2;90;100;128m' # text-muted #5a6480
NC='\033[0m' # No Color
DEFAULT_TAGLINE="AI agents powered by your existing GitHub Copilot subscription."
ORIGINAL_PATH="${PATH:-}"
TMPFILES=()
cleanup_tmpfiles() {
local f
for f in "${TMPFILES[@]:-}"; do
rm -rf "$f" 2>/dev/null || true
done
}
trap cleanup_tmpfiles EXIT
mktempfile() {
local f
f="$(mktemp)"
TMPFILES+=("$f")
echo "$f"
}
DOWNLOADER=""
detect_downloader() {
if command -v curl &> /dev/null; then
DOWNLOADER="curl"
return 0
fi
if command -v wget &> /dev/null; then
DOWNLOADER="wget"
return 0
fi
ui_error "Missing downloader (curl or wget required)"
exit 1
}
download_file() {
local url="$1"
local output="$2"
if [[ -z "$DOWNLOADER" ]]; then
detect_downloader
fi
if [[ "$DOWNLOADER" == "curl" ]]; then
curl -fsSL --proto '=https' --tlsv1.2 --retry 3 --retry-delay 1 --retry-connrefused -o "$output" "$url"
return
fi
wget -q --https-only --secure-protocol=TLSv1_2 --tries=3 --timeout=20 -O "$output" "$url"
}
run_remote_bash() {
local url="$1"
local tmp
tmp="$(mktempfile)"
download_file "$url" "$tmp"
/bin/bash "$tmp"
}
# ── Retry wrapper for network operations ────────────────────
retry() {
local max_attempts="$1"
local delay="$2"
shift 2
local attempt=1
while true; do
if "$@"; then
return 0
fi
if [[ "$attempt" -ge "$max_attempts" ]]; then
return 1
fi
ui_info "Retrying ($attempt/$max_attempts) in ${delay}s..."
sleep "$delay"
((attempt++))
delay=$((delay * 2 > 30 ? 30 : delay * 2))
done
}
# ── Gum (fancy terminal UI) ────────────────────────────────
GUM_VERSION="${OPENRAPPTER_GUM_VERSION:-0.17.0}"
GUM=""
GUM_STATUS="skipped"
GUM_REASON=""
gum_is_tty() {
if [[ -n "${NO_COLOR:-}" ]]; then
return 1
fi
if [[ "${TERM:-dumb}" == "dumb" ]]; then
return 1
fi
if [[ -t 2 || -t 1 ]]; then
return 0
fi
if [[ -r /dev/tty && -w /dev/tty ]]; then
return 0
fi
return 1
}
gum_detect_os() {
case "$(uname -s 2>/dev/null || true)" in
Darwin) echo "Darwin" ;;
Linux) echo "Linux" ;;
*) echo "unsupported" ;;
esac
}
gum_detect_arch() {
case "$(uname -m 2>/dev/null || true)" in
x86_64|amd64) echo "x86_64" ;;
arm64|aarch64) echo "arm64" ;;
i386|i686) echo "i386" ;;
armv7l|armv7) echo "armv7" ;;
armv6l|armv6) echo "armv6" ;;
*) echo "unknown" ;;
esac
}
verify_sha256sum_file() {
local checksums="$1"
if command -v sha256sum >/dev/null 2>&1; then
sha256sum --ignore-missing -c "$checksums" >/dev/null 2>&1
return $?
fi
if command -v shasum >/dev/null 2>&1; then
shasum -a 256 --ignore-missing -c "$checksums" >/dev/null 2>&1
return $?
fi
return 1
}
bootstrap_gum_temp() {
GUM=""
GUM_STATUS="skipped"
GUM_REASON=""
case "$OPENRAPPTER_USE_GUM" in
0|false|False|FALSE|off|OFF|no|NO)
GUM_REASON="disabled via OPENRAPPTER_USE_GUM"
return 1
;;
esac
if ! gum_is_tty; then
GUM_REASON="not a TTY"
return 1
fi
if command -v gum >/dev/null 2>&1; then
GUM="gum"
GUM_STATUS="found"
GUM_REASON="already installed"
return 0
fi
if [[ "$OPENRAPPTER_USE_GUM" != "1" && "$OPENRAPPTER_USE_GUM" != "true" && "$OPENRAPPTER_USE_GUM" != "TRUE" ]]; then
if [[ "$OPENRAPPTER_USE_GUM" != "auto" ]]; then
GUM_REASON="invalid OPENRAPPTER_USE_GUM value: $OPENRAPPTER_USE_GUM"
return 1
fi
fi
if ! command -v tar >/dev/null 2>&1; then
GUM_REASON="tar not found"
return 1
fi
local os arch asset base gum_tmpdir gum_path
os="$(gum_detect_os)"
arch="$(gum_detect_arch)"
if [[ "$os" == "unsupported" || "$arch" == "unknown" ]]; then
GUM_REASON="unsupported os/arch ($os/$arch)"
return 1
fi
asset="gum_${GUM_VERSION}_${os}_${arch}.tar.gz"
base="https://github.com/charmbracelet/gum/releases/download/v${GUM_VERSION}"
gum_tmpdir="$(mktemp -d)"
TMPFILES+=("$gum_tmpdir")
if ! download_file "${base}/${asset}" "$gum_tmpdir/$asset"; then
GUM_REASON="download failed"
return 1
fi
if ! download_file "${base}/checksums.txt" "$gum_tmpdir/checksums.txt"; then
GUM_REASON="checksum unavailable or failed"
return 1
fi
if ! (cd "$gum_tmpdir" && verify_sha256sum_file "checksums.txt"); then
GUM_REASON="checksum unavailable or failed"
return 1
fi
if ! tar -xzf "$gum_tmpdir/$asset" -C "$gum_tmpdir" >/dev/null 2>&1; then
GUM_REASON="extract failed"
return 1
fi
gum_path="$(find "$gum_tmpdir" -type f -name gum 2>/dev/null | head -n1 || true)"
if [[ -z "$gum_path" ]]; then
GUM_REASON="gum binary missing after extract"
return 1
fi
chmod +x "$gum_path" >/dev/null 2>&1 || true
if [[ ! -x "$gum_path" ]]; then
GUM_REASON="gum binary is not executable"
return 1
fi
GUM="$gum_path"
GUM_STATUS="installed"
GUM_REASON="temp, verified"
return 0
}
print_gum_status() {
case "$GUM_STATUS" in
found)
ui_success "gum available (${GUM_REASON})"
;;
installed)
ui_success "gum bootstrapped (${GUM_REASON}, v${GUM_VERSION})"
;;
*)
if [[ -n "$GUM_REASON" ]]; then
ui_info "gum skipped (${GUM_REASON})"
fi
;;
esac
}
# ── UI Functions ────────────────────────────────────────────
print_installer_banner() {
if [[ -n "$GUM" ]]; then
local title tagline hint card
title="$("$GUM" style --foreground "#10b981" --bold "🦖 OpenRappter Installer")"
tagline="$("$GUM" style --foreground "#8892b0" "$TAGLINE")"
hint="$("$GUM" style --foreground "#5a6480" "modern installer mode")"
card="$(printf '%s\n%s\n%s' "$title" "$tagline" "$hint")"
"$GUM" style --border rounded --border-foreground "#10b981" --padding "1 2" "$card"
echo ""
return
fi
echo -e "${ACCENT}${BOLD}"
echo " 🦖 OpenRappter Installer"
echo -e "${NC}${INFO} ${TAGLINE}${NC}"
echo ""
}
detect_os_or_die() {
OS="unknown"
if [[ "$OSTYPE" == "darwin"* ]]; then
OS="macos"
elif [[ "$OSTYPE" == "linux-gnu"* ]] || [[ -n "${WSL_DISTRO_NAME:-}" ]]; then
OS="linux"
fi
if [[ "$OS" == "unknown" ]]; then
ui_error "Unsupported operating system"
echo "This installer supports macOS and Linux (including WSL)."
exit 1
fi
ui_success "Detected: $OS"
}
detect_arch() {
case "$(uname -m 2>/dev/null || true)" in
x86_64|amd64) echo "x64" ;;
arm64|aarch64) echo "arm64" ;;
*) uname -m ;;
esac
}
ui_info() {
local msg="$*"
if [[ -n "$GUM" ]]; then
"$GUM" log --level info "$msg"
else
echo -e "${MUTED}·${NC} ${msg}"
fi
}
ui_warn() {
local msg="$*"
if [[ -n "$GUM" ]]; then
"$GUM" log --level warn "$msg"
else
echo -e "${WARN}!${NC} ${msg}"
fi
}
ui_success() {
local msg="$*"
if [[ -n "$GUM" ]]; then
local mark
mark="$("$GUM" style --foreground "#00e5cc" --bold "✓")"
echo "${mark} ${msg}"
else
echo -e "${SUCCESS}✓${NC} ${msg}"
fi
}
ui_error() {
local msg="$*"
if [[ -n "$GUM" ]]; then
"$GUM" log --level error "$msg"
else
echo -e "${ERROR}✗${NC} ${msg}"
fi
}
INSTALL_STAGE_TOTAL=4
INSTALL_STAGE_CURRENT=0
ui_section() {
local title="$1"
if [[ -n "$GUM" ]]; then
"$GUM" style --bold --foreground "#10b981" --padding "1 0" "$title"
else
echo ""
echo -e "${ACCENT}${BOLD}${title}${NC}"
fi
}
ui_stage() {
local title="$1"
INSTALL_STAGE_CURRENT=$((INSTALL_STAGE_CURRENT + 1))
ui_section "[${INSTALL_STAGE_CURRENT}/${INSTALL_STAGE_TOTAL}] ${title}"
}
ui_kv() {
local key="$1"
local value="$2"
if [[ -n "$GUM" ]]; then
local key_part value_part
key_part="$("$GUM" style --foreground "#5a6480" --width 20 "$key")"
value_part="$("$GUM" style --bold "$value")"
"$GUM" join --horizontal "$key_part" "$value_part"
else
echo -e "${MUTED}${key}:${NC} ${value}"
fi
}
ui_panel() {
local content="$1"
if [[ -n "$GUM" ]]; then
"$GUM" style --border rounded --border-foreground "#5a6480" --padding "0 1" "$content"
else
echo "$content"
fi
}
ui_celebrate() {
local msg="$1"
if [[ -n "$GUM" ]]; then
"$GUM" style --bold --foreground "#00e5cc" "$msg"
else
echo -e "${SUCCESS}${BOLD}${msg}${NC}"
fi
}
# Numpad-friendly menu: type a number to choose (no arrow keys needed)
# Usage: ui_choose "Header text" "Option A" "Option B" ...
# Returns: selected option text on stdout
# Supports gum as visual upgrade, falls back to pure bash numpad input
ui_choose() {
local header="$1"
shift
local options=("$@")
local count=${#options[@]}
if [[ "$count" -eq 0 ]]; then
return 1
fi
# Single option — auto-select
if [[ "$count" -eq 1 ]]; then
echo "${options[0]}"
return 0
fi
# Display header and numbered options
echo "" >&2
echo -e "${ACCENT}${BOLD}${header}${NC}" >&2
echo "" >&2
for i in "${!options[@]}"; do
local num=$((i + 1))
echo -e " ${CYAN}${BOLD}${num}${NC} ${options[$i]}" >&2
done
echo "" >&2
# Read numpad input
while true; do
echo -n -e "${MUTED}Enter number [1-${count}]:${NC} " >&2
local input
read -r input </dev/tty 2>/dev/null || read -r input
# Strip whitespace
input="${input// /}"
if [[ "$input" =~ ^[0-9]+$ ]] && (( input >= 1 && input <= count )); then
echo "${options[$((input - 1))]}"
return 0
fi
echo -e "${WARN} Please enter a number between 1 and ${count}${NC}" >&2
done
}
is_shell_function() {
local name="${1:-}"
[[ -n "$name" ]] && declare -F "$name" >/dev/null 2>&1
}
run_with_spinner() {
local title="$1"
shift
if [[ -n "$GUM" ]] && gum_is_tty && ! is_shell_function "${1:-}"; then
"$GUM" spin --spinner dot --title "$title" -- "$@"
return $?
fi
"$@"
}
run_quiet_step() {
local title="$1"
shift
if [[ "$VERBOSE" == "1" ]]; then
run_with_spinner "$title" "$@"
return $?
fi
local log
log="$(mktempfile)"
if [[ -n "$GUM" ]] && gum_is_tty && ! is_shell_function "${1:-}"; then
local cmd_quoted=""
local log_quoted=""
printf -v cmd_quoted '%q ' "$@"
printf -v log_quoted '%q' "$log"
if run_with_spinner "$title" bash -c "${cmd_quoted}>${log_quoted} 2>&1"; then
return 0
fi
else
if "$@" >"$log" 2>&1; then
return 0
fi
fi
ui_error "${title} failed — re-run with --verbose for details"
if [[ -s "$log" ]]; then
tail -n 80 "$log" >&2 || true
fi
return 1
}
show_install_plan() {
ui_section "Install plan"
ui_kv "OS" "$OS"
ui_kv "Method" "${INSTALL_METHOD:-auto}"
if [[ "$INSTALL_METHOD" == "git" ]]; then
ui_kv "Install directory" "$INSTALL_DIR"
fi
ui_kv "Node.js minimum" "v${MIN_NODE}+"
ui_kv "Python" "optional (3.${MIN_PYTHON_MINOR}+)"
if [[ "${OPT_NO_COPILOT:-false}" == "true" ]]; then
ui_kv "Copilot" "skipped (--no-copilot)"
fi
if [[ "$DRY_RUN" == "1" ]]; then
ui_kv "Dry run" "yes"
fi
}
show_footer_links() {
local docs_url="https://kody-w.github.io/openrappter"
if [[ -n "$GUM" ]]; then
local content
content="$(printf '%s\n%s' "Need help?" "Docs: ${docs_url}")"
ui_panel "$content"
else
echo ""
echo -e "Docs: ${INFO}${docs_url}${NC}"
fi
}
# ── Taglines ────────────────────────────────────────────────
TAGLINES=()
TAGLINES+=("Your terminal just evolved — type something and let the raptor handle the busywork.")
TAGLINES+=("Welcome to the command line: where agents compile and confidence segfaults.")
TAGLINES+=("I run on caffeine, JSON5, and the audacity of \"it worked on my machine.\"")
TAGLINES+=("Gateway online — please keep hands, feet, and appendages inside the shell at all times.")
TAGLINES+=("I speak fluent bash, mild sarcasm, and aggressive tab-completion energy.")
TAGLINES+=("One CLI to rule them all, and one more restart because you changed the port.")
TAGLINES+=("If it works, it's automation; if it breaks, it's a \"learning opportunity.\"")
TAGLINES+=("Your .env is showing; don't worry, I'll pretend I didn't see it.")
TAGLINES+=("I'll do the boring stuff while you dramatically stare at the logs like it's cinema.")
TAGLINES+=("Type the command with confidence — nature will provide the stack trace if needed.")
TAGLINES+=("I can grep it, git blame it, and gently roast it — pick your coping mechanism.")
TAGLINES+=("Hot reload for config, cold sweat for deploys.")
TAGLINES+=("I'm the assistant your terminal demanded, not the one your sleep schedule requested.")
TAGLINES+=("Automation with claws: minimal fuss, maximal pinch.")
TAGLINES+=("I'm basically a Swiss Army knife, but with more opinions and fewer sharp edges.")
TAGLINES+=("Your task has been queued; your dignity has been deprecated.")
TAGLINES+=("I can't fix your code taste, but I can fix your build and your backlog.")
TAGLINES+=("I'm not magic — I'm just extremely persistent with retries and coping strategies.")
TAGLINES+=("It's not \"failing,\" it's \"discovering new ways to configure the same thing wrong.\"")
TAGLINES+=("I read logs so you can keep pretending you don't have to.")
TAGLINES+=("I'll refactor your busywork like it owes me money.")
TAGLINES+=("I'm like tmux: confusing at first, then suddenly you can't live without me.")
TAGLINES+=("If you can describe it, I can probably automate it — or at least make it funnier.")
TAGLINES+=("Your config is valid, your assumptions are not.")
TAGLINES+=("Less clicking, more shipping, fewer \"where did that file go\" moments.")
TAGLINES+=("AI agents powered by your existing GitHub Copilot subscription.")
TAGLINES+=("No extra API keys. No new accounts. No additional monthly bills.")
TAGLINES+=("Your data stays local. Your agents stay loyal. 🦖")
TAGLINES+=("Dual runtime. Single file agents. Zero API keys.")
TAGLINES+=("Data sloshing: because your agents deserve context, not just commands.")
TAGLINES+=("Who needs API keys when you have GitHub Copilot?")
TAGLINES+=("Shell yeah — I'm here to automate the toil and leave you the glory.")
TAGLINES+=("The raptor has entered the chat. Your workflow will never be the same.")
TAGLINES+=("Local-first AI that actually remembers things. Revolutionary, we know.")
TAGLINES+=("pip install was so last season. curl | bash is the new hotness.")
TAGLINES+=("npm install -g openrappter — because you deserve nice things.")
TAGLINES+=("One command to install, zero commands to regret.")
TAGLINES+=("I'm not saying I'm better than your last framework, but… actually yes, I am.")
TAGLINES+=("Installing globally because commitment issues are for other packages.")
TAGLINES+=("Your PATH is about to get a lot more interesting.")
TAGLINES+=("Build tools? I'll handle those. You just sit there and look productive.")
TAGLINES+=("Gateway restart? More like gateway glow-up.")
TAGLINES+=("I auto-detect your install method. I'm basically psychic, but for shells.")
TAGLINES+=("npm or git? Why not both? (But npm is faster, just saying.)")
TAGLINES+=("The installer that installs installers. Wait, no — just the one you need.")
TAGLINES+=("Conflict resolution: not just for diplomats anymore.")
TAGLINES+=("Doctor's orders: your config needs a checkup after every upgrade.")
HOLIDAY_NEW_YEAR="New Year's Day: New year, new config — same old EADDRINUSE, but this time we resolve it like grown-ups."
HOLIDAY_LUNAR_NEW_YEAR="Lunar New Year: May your builds be lucky, your branches prosperous, and your merge conflicts chased away with fireworks."
HOLIDAY_CHRISTMAS="Christmas: Ho ho ho — Santa's little raptor-sistant is here to ship joy, roll back chaos, and stash the keys safely."
HOLIDAY_EID="Eid al-Fitr: Celebration mode: queues cleared, tasks completed, and good vibes committed to main with clean history."
HOLIDAY_DIWALI="Diwali: Let the logs sparkle and the bugs flee — today we light up the terminal and ship with pride."
HOLIDAY_EASTER="Easter: I found your missing environment variable — consider it a tiny CLI egg hunt with fewer jellybeans."
HOLIDAY_HANUKKAH="Hanukkah: Eight nights, eight retries, zero shame — may your gateway stay lit and your deployments stay peaceful."
HOLIDAY_HALLOWEEN="Halloween: Spooky season: beware haunted dependencies, cursed caches, and the ghost of node_modules past."
HOLIDAY_THANKSGIVING="Thanksgiving: Grateful for stable ports, working DNS, and an agent that reads the logs so nobody has to."
HOLIDAY_VALENTINES="Valentine's Day: Roses are typed, violets are piped — I'll automate the chores so you can spend time with humans."
append_holiday_taglines() {
local today
local month_day
today="$(date -u +%Y-%m-%d 2>/dev/null || date +%Y-%m-%d)"
month_day="$(date -u +%m-%d 2>/dev/null || date +%m-%d)"
case "$month_day" in
"01-01") TAGLINES+=("$HOLIDAY_NEW_YEAR") ;;
"02-14") TAGLINES+=("$HOLIDAY_VALENTINES") ;;
"10-31") TAGLINES+=("$HOLIDAY_HALLOWEEN") ;;
"12-25") TAGLINES+=("$HOLIDAY_CHRISTMAS") ;;
esac
case "$today" in
"2025-01-29"|"2026-02-17"|"2027-02-06") TAGLINES+=("$HOLIDAY_LUNAR_NEW_YEAR") ;;
"2025-03-30"|"2025-03-31"|"2026-03-20"|"2027-03-10") TAGLINES+=("$HOLIDAY_EID") ;;
"2025-10-20"|"2026-11-08"|"2027-10-28") TAGLINES+=("$HOLIDAY_DIWALI") ;;
"2025-04-20"|"2026-04-05"|"2027-03-28") TAGLINES+=("$HOLIDAY_EASTER") ;;
"2025-11-27"|"2026-11-26"|"2027-11-25") TAGLINES+=("$HOLIDAY_THANKSGIVING") ;;
"2025-12-15"|"2025-12-16"|"2025-12-17"|"2025-12-18"|"2025-12-19"|"2025-12-20"|"2025-12-21"|"2025-12-22"|"2026-12-05"|"2026-12-06"|"2026-12-07"|"2026-12-08"|"2026-12-09"|"2026-12-10"|"2026-12-11"|"2026-12-12"|"2027-12-25"|"2027-12-26"|"2027-12-27"|"2027-12-28"|"2027-12-29"|"2027-12-30"|"2027-12-31"|"2028-01-01") TAGLINES+=("$HOLIDAY_HANUKKAH") ;;
esac
}
pick_tagline() {
append_holiday_taglines
local count=${#TAGLINES[@]}
if [[ "$count" -eq 0 ]]; then
echo "$DEFAULT_TAGLINE"
return
fi
if [[ -n "${OPENRAPPTER_TAGLINE_INDEX:-}" ]]; then
if [[ "${OPENRAPPTER_TAGLINE_INDEX}" =~ ^[0-9]+$ ]]; then
local idx=$((OPENRAPPTER_TAGLINE_INDEX % count))
echo "${TAGLINES[$idx]}"
return
fi
fi
local idx=$((RANDOM % count))
echo "${TAGLINES[$idx]}"
}
TAGLINE=$(pick_tagline)
# ── Configuration ───────────────────────────────────────────
DRY_RUN=${OPENRAPPTER_DRY_RUN:-0}
VERBOSE="${OPENRAPPTER_VERBOSE:-0}"
OPENRAPPTER_USE_GUM="${OPENRAPPTER_USE_GUM:-auto}"
HELP=0
REPO_URL="https://github.com/kody-w/openrappter.git"
INSTALL_DIR="${OPENRAPPTER_HOME:-$HOME/.openrappter}"
MIN_NODE=20
MIN_PYTHON_MINOR=10
BIN_NAME="openrappter"
NPM_PACKAGE="openrappter"
# Install method: "npm", "git", or "" (auto-detect/prompt)
INSTALL_METHOD="${OPENRAPPTER_INSTALL_METHOD:-}"
OPT_NO_PROMPT="${OPENRAPPTER_NO_PROMPT:-false}"
OPT_SET_NPM_PREFIX=false
print_usage() {
cat <<EOF
OpenRappter installer (macOS + Linux)
Usage:
curl -fsSL https://kody-w.github.io/openrappter/install.sh | bash
curl -fsSL https://kody-w.github.io/openrappter/install.sh | bash -s -- [options]
Options:
--method npm|git Install method (default: npm)
--dir <path> Install directory for git method (default: ~/.openrappter)
--dry-run Print what would happen (no changes)
--verbose Print debug output
--no-prompt Non-interactive mode (CI/automation)
--set-npm-prefix Force npm prefix fix (Linux EACCES workaround)
--gum Force gum UI if possible
--no-gum Disable gum UI
--no-copilot Skip Copilot setup entirely
--no-onboard Skip onboard wizard
--help, -h Show this help
Environment variables:
OPENRAPPTER_HOME=... Install directory (default: ~/.openrappter)
OPENRAPPTER_INSTALL_METHOD=npm|git Install method override
OPENRAPPTER_VERSION=1.4.0 Pin specific version (npm method)
OPENRAPPTER_BETA=1 Install @beta tag (npm method)
OPENRAPPTER_NO_PROMPT=true Non-interactive mode
OPENRAPPTER_DRY_RUN=1 Dry run mode
OPENRAPPTER_VERBOSE=1 Verbose output
OPENRAPPTER_USE_GUM=auto|1|0 Default: auto (try gum on interactive TTY)
SHARP_IGNORE_GLOBAL_LIBVIPS=1 Skip global libvips download (set automatically)
Examples:
curl -fsSL https://kody-w.github.io/openrappter/install.sh | bash
curl -fsSL https://kody-w.github.io/openrappter/install.sh | bash -s -- --method npm
curl -fsSL https://kody-w.github.io/openrappter/install.sh | bash -s -- --method git --verbose
curl -fsSL https://kody-w.github.io/openrappter/install.sh | bash -s -- --no-prompt --no-copilot
EOF
}
parse_args() {
while [[ $# -gt 0 ]]; do
case "$1" in
--method)
INSTALL_METHOD="$2"
shift 2
;;
--no-prompt)
OPT_NO_PROMPT=true
shift
;;
--set-npm-prefix)
OPT_SET_NPM_PREFIX=true
shift
;;
--dry-run)
DRY_RUN=1
shift
;;
--verbose)
VERBOSE=1
shift
;;
--gum)
OPENRAPPTER_USE_GUM=1
shift
;;
--no-gum)
OPENRAPPTER_USE_GUM=0
shift
;;
--no-onboard)
OPT_NO_ONBOARD=true
shift
;;
--no-copilot)
OPT_NO_COPILOT=true
shift
;;
--dir)
INSTALL_DIR="$2"
shift 2
;;
--help|-h)
HELP=1
shift
;;
*)
shift
;;
esac
done
}
configure_verbose() {
if [[ "$VERBOSE" != "1" ]]; then
return 0
fi
set -x
}
# ── OS & Tooling ────────────────────────────────────────────
is_root() {
[[ "$(id -u)" -eq 0 ]]
}
maybe_sudo() {
if is_root; then
if [[ "${1:-}" == "-E" ]]; then
shift
fi
"$@"
else
sudo "$@"
fi
}
require_sudo() {
if [[ "$OS" != "linux" ]]; then
return 0
fi
if is_root; then
return 0
fi
if command -v sudo &> /dev/null; then
if ! sudo -n true >/dev/null 2>&1; then
ui_info "Administrator privileges required; enter your password"
sudo -v
fi
return 0
fi
ui_error "sudo is required for system installs on Linux"
echo " Install sudo or re-run as root."
exit 1
}
refresh_shell_command_cache() {
hash -r 2>/dev/null || true
}
# ── Homebrew (macOS) ────────────────────────────────────────
install_homebrew() {
if [[ "$OS" == "macos" ]]; then
if ! command -v brew &> /dev/null; then
ui_info "Homebrew not found, installing"
run_quiet_step "Installing Homebrew" run_remote_bash "https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh"
if [[ -f "/opt/homebrew/bin/brew" ]]; then
eval "$(/opt/homebrew/bin/brew shellenv)"
elif [[ -f "/usr/local/bin/brew" ]]; then
eval "$(/usr/local/bin/brew shellenv)"
fi
ui_success "Homebrew installed"
else
ui_success "Homebrew already installed"
fi
fi
}
# ── Node.js ─────────────────────────────────────────────────
get_node_major() {
if command -v node &>/dev/null; then
node --version 2>/dev/null | sed 's/^v//' | cut -d. -f1
else
echo "0"
fi
}
check_node() {
# Try to find node on PATH first
if command -v node &>/dev/null; then
local node_ver
node_ver=$(node -v | cut -d'v' -f2 | cut -d'.' -f1)
if [[ "$node_ver" -ge "$MIN_NODE" ]]; then
ui_success "Node.js v$(node -v | cut -d'v' -f2) found"
return 0
else
ui_info "Node.js $(node -v) found but need v${MIN_NODE}+"
fi
fi
# Node not found or too old — try sourcing version managers
# (they may have installed node but not sourced into this shell)
source_nvm_if_present
source_fnm_if_present
# Check common install locations not yet on PATH
local extra_paths=(
"$HOME/.local/bin"
"/usr/local/bin"
"/opt/homebrew/bin"
"$HOME/.volta/bin"
)
# mise shims
local mise_data="${MISE_DATA_DIR:-$HOME/.local/share/mise}"
if [[ -d "$mise_data/shims" ]]; then
extra_paths+=("$mise_data/shims")
fi
for p in "${extra_paths[@]}"; do
if [[ -x "$p/node" ]] && ! command -v node &>/dev/null; then
export PATH="$p:$PATH"
fi
done
refresh_shell_command_cache
if command -v node &>/dev/null; then
local node_ver
node_ver=$(node -v | cut -d'v' -f2 | cut -d'.' -f1)
if [[ "$node_ver" -ge "$MIN_NODE" ]]; then
ui_success "Node.js v$(node -v | cut -d'v' -f2) found (via PATH discovery)"
return 0
else
ui_info "Node.js $(node -v) found but need v${MIN_NODE}+ — upgrading"
return 1
fi
fi
ui_info "Node.js not found, installing it now"
return 1
}
install_node() {
# ── Strategy: try multiple approaches in order of preference ──
# 1. Existing version managers (nvm, fnm, volta, mise, asdf)
# 2. Platform package manager (Homebrew / NodeSource)
# 3. Fresh nvm install
# 4. Direct Node.js tarball download (last resort, no root needed)
# Source any existing version manager environments first
source_nvm_if_present
source_fnm_if_present
# 1. Try existing version managers
if try_version_managers; then
return 0
fi
# 2. Try platform package manager
if [[ "$OS" == "macos" ]]; then
if command -v brew &>/dev/null; then
ui_info "Installing Node.js via Homebrew"
if run_quiet_step "Installing node@${MIN_NODE}" brew install "node@${MIN_NODE}"; then
brew link "node@${MIN_NODE}" --overwrite --force 2>/dev/null || true
refresh_shell_command_cache
if verify_node_version; then
ui_success "Node.js $(node --version) installed via Homebrew"
return 0
fi
fi
ui_info "Homebrew install didn't produce a usable Node — trying next method"
fi
elif [[ "$OS" == "linux" ]]; then
local nodesource_ok=false
if command -v apt-get &>/dev/null; then
ui_info "Installing Node.js via NodeSource (apt)"
require_sudo
local tmp
tmp="$(mktempfile)"
if download_file "https://deb.nodesource.com/setup_${MIN_NODE}.x" "$tmp" 2>/dev/null; then
if is_root; then
run_quiet_step "Configuring NodeSource repository" bash "$tmp" && \
run_quiet_step "Installing Node.js" apt-get install -y -qq nodejs && nodesource_ok=true
else
run_quiet_step "Configuring NodeSource repository" sudo -E bash "$tmp" && \
run_quiet_step "Installing Node.js" sudo apt-get install -y -qq nodejs && nodesource_ok=true
fi
fi
elif command -v dnf &>/dev/null; then
ui_info "Installing Node.js via NodeSource (dnf)"
require_sudo
local tmp
tmp="$(mktempfile)"
if download_file "https://rpm.nodesource.com/setup_${MIN_NODE}.x" "$tmp" 2>/dev/null; then
if is_root; then
run_quiet_step "Configuring NodeSource repository" bash "$tmp" && \
run_quiet_step "Installing Node.js" dnf install -y -q nodejs && nodesource_ok=true
else
run_quiet_step "Configuring NodeSource repository" sudo bash "$tmp" && \
run_quiet_step "Installing Node.js" sudo dnf install -y -q nodejs && nodesource_ok=true
fi
fi
elif command -v yum &>/dev/null; then
ui_info "Installing Node.js via NodeSource (yum)"
require_sudo
local tmp
tmp="$(mktempfile)"
if download_file "https://rpm.nodesource.com/setup_${MIN_NODE}.x" "$tmp" 2>/dev/null; then
if is_root; then
run_quiet_step "Configuring NodeSource repository" bash "$tmp" && \
run_quiet_step "Installing Node.js" yum install -y -q nodejs && nodesource_ok=true
else
run_quiet_step "Configuring NodeSource repository" sudo bash "$tmp" && \
run_quiet_step "Installing Node.js" sudo yum install -y -q nodejs && nodesource_ok=true
fi
fi
fi
if [[ "$nodesource_ok" == "true" ]]; then
refresh_shell_command_cache
if verify_node_version; then
ui_success "Node.js $(node --version) installed via NodeSource"
return 0
fi
fi
ui_info "NodeSource install didn't succeed — trying next method"
fi
# 3. Try fresh nvm install
ui_info "Trying Node.js installation via nvm (fresh install)"
if install_node_nvm 2>/dev/null; then
refresh_shell_command_cache
if verify_node_version; then
return 0
fi
fi
ui_info "nvm install didn't succeed — trying direct download"
# 4. Last resort: direct tarball download (no root needed)
if install_node_tarball; then
return 0
fi
# All methods failed — give a helpful error
ui_error "Could not install Node.js v${MIN_NODE}+"
echo ""
echo " Detected node: $(command -v node 2>/dev/null || echo 'not found')"
echo " Node version: $(node --version 2>/dev/null || echo 'unknown')"
echo " PATH: $PATH"
echo ""
echo " Manual install options:"
echo " https://nodejs.org/en/download"
echo " nvm install ${MIN_NODE}"
echo " brew install node@${MIN_NODE}"
echo " fnm install ${MIN_NODE}"
echo " volta install node@${MIN_NODE}"
exit 1
}
install_node_nvm() {
if [[ ! -d "$HOME/.nvm" ]]; then
run_quiet_step "Installing nvm" run_remote_bash "https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh"
fi
export NVM_DIR="$HOME/.nvm"
# shellcheck disable=SC1091
[[ -s "$NVM_DIR/nvm.sh" ]] && . "$NVM_DIR/nvm.sh"
nvm install "$MIN_NODE" --default
nvm use "$MIN_NODE"
ui_success "Node.js $(node --version) installed via nvm"
}
# ── Node.js verification ────────────────────────────────────
verify_node_version() {
refresh_shell_command_cache
if ! command -v node &>/dev/null; then
return 1
fi
local ver
ver="$(node --version 2>/dev/null | sed 's/^v//' | cut -d. -f1)"
if [[ "$ver" -ge "$MIN_NODE" ]] 2>/dev/null; then
return 0
fi
return 1
}
# ── Version Manager Detection ───────────────────────────────
source_nvm_if_present() {