-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathinstall.sh
More file actions
2539 lines (2243 loc) · 79.6 KB
/
install.sh
File metadata and controls
2539 lines (2243 loc) · 79.6 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
# OpenAEON Installer for macOS and Linux
# Usage: curl -fsSL --proto '=https' --tlsv1.2 https://raw.githubusercontent.com/openaeon/OpenAEON/main/install.sh | bash
BOLD='\033[1m'
ACCENT='\033[38;2;255;77;77m' # coral-bright #ff4d4d
# shellcheck disable=SC2034
ACCENT_BRIGHT='\033[38;2;255;110;110m' # lighter coral
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 (no site equiv, keep warm)
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="All your chats, one OpenAEON."
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"
}
GUM_VERSION="${OPENAEON_GUM_VERSION:-0.17.0}"
GUM=""
GUM_STATUS="skipped"
GUM_REASON=""
LAST_NPM_INSTALL_CMD=""
is_non_interactive_shell() {
if [[ "${NO_PROMPT:-0}" == "1" ]]; then
return 0
fi
if [[ ! -t 0 || ! -t 1 ]]; then
return 0
fi
return 1
}
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=""
if is_non_interactive_shell; then
GUM_REASON="non-interactive shell (auto-disabled)"
return 1
fi
if ! gum_is_tty; then
GUM_REASON="terminal does not support gum UI"
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 ! 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" && "$GUM_REASON" != "non-interactive shell (auto-disabled)" ]]; then
ui_info "gum skipped (${GUM_REASON})"
fi
;;
esac
}
print_installer_banner() {
if [[ -n "$GUM" ]]; then
local title tagline hint card
title="$("$GUM" style --foreground "#ff4d4d" --bold "🦞 OpenAEON 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 "#ff4d4d" --padding "1 2" "$card"
echo ""
return
fi
echo -e "${ACCENT}${BOLD}"
echo " 🦞 OpenAEON 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)."
echo "For Windows, use: iwr -useb https://openaeon.ai/install.ps1 | iex"
exit 1
fi
ui_success "Detected: $OS"
}
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=3
INSTALL_STAGE_CURRENT=0
ui_section() {
local title="$1"
if [[ -n "$GUM" ]]; then
"$GUM" style --bold --foreground "#ff4d4d" --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
}
show_install_plan() {
local detected_checkout="$1"
ui_section "Install plan"
ui_kv "OS" "$OS"
ui_kv "Install method" "$INSTALL_METHOD"
ui_kv "Requested version" "$OPENAEON_VERSION"
if [[ "$USE_BETA" == "1" ]]; then
ui_kv "Beta channel" "enabled"
fi
if [[ "$INSTALL_METHOD" == "git" ]]; then
ui_kv "Git directory" "$GIT_DIR"
ui_kv "Git update" "$GIT_UPDATE"
fi
if [[ -n "$detected_checkout" ]]; then
ui_kv "Detected checkout" "$detected_checkout"
fi
if [[ "$DRY_RUN" == "1" ]]; then
ui_kv "Dry run" "yes"
fi
if [[ "$NO_ONBOARD" == "1" ]]; then
ui_kv "Onboarding" "skipped"
fi
}
show_footer_links() {
local faq_url="https://docs.openaeon.ai/start/faq"
if [[ -n "$GUM" ]]; then
local content
content="$(printf '%s\n%s' "Need help?" "FAQ: ${faq_url}")"
ui_panel "$content"
else
echo ""
echo -e "FAQ: ${INFO}${faq_url}${NC}"
fi
}
ui_celebrate() {
local msg="$1"
if [[ -n "$GUM" ]]; then
"$GUM" style --bold --foreground "#00e5cc" "$msg"
else
echo -e "${SUCCESS}${BOLD}${msg}${NC}"
fi
}
is_shell_function() {
local name="${1:-}"
[[ -n "$name" ]] && declare -F "$name" >/dev/null 2>&1
}
is_gum_raw_mode_failure() {
local err_log="$1"
[[ -s "$err_log" ]] || return 1
grep -Eiq 'setrawmode' "$err_log"
}
run_with_spinner() {
local title="$1"
shift
if [[ -n "$GUM" ]] && gum_is_tty && ! is_shell_function "${1:-}"; then
local gum_err
gum_err="$(mktempfile)"
if "$GUM" spin --spinner dot --title "$title" -- "$@" 2>"$gum_err"; then
return 0
fi
local gum_status=$?
if is_gum_raw_mode_failure "$gum_err"; then
GUM=""
GUM_STATUS="skipped"
GUM_REASON="gum raw mode unavailable"
ui_warn "Spinner unavailable in this terminal; continuing without spinner"
"$@"
return $?
fi
if [[ -s "$gum_err" ]]; then
cat "$gum_err" >&2
fi
return "$gum_status"
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
}
cleanup_legacy_submodules() {
local repo_dir="$1"
local legacy_dir="$repo_dir/Peekaboo"
if [[ -d "$legacy_dir" ]]; then
ui_info "Removing legacy submodule checkout: ${legacy_dir}"
rm -rf "$legacy_dir"
fi
}
cleanup_npm_openaeon_paths() {
local npm_root=""
npm_root="$(npm root -g 2>/dev/null || true)"
if [[ -z "$npm_root" || "$npm_root" != *node_modules* ]]; then
return 1
fi
rm -rf "$npm_root"/.openaeon-* "$npm_root"/openaeon 2>/dev/null || true
}
extract_openaeon_conflict_path() {
local log="$1"
local path=""
path="$(sed -n 's/.*File exists: //p' "$log" | head -n1)"
if [[ -z "$path" ]]; then
path="$(sed -n 's/.*EEXIST: file already exists, //p' "$log" | head -n1)"
fi
if [[ -n "$path" ]]; then
echo "$path"
return 0
fi
return 1
}
cleanup_openaeon_bin_conflict() {
local bin_path="$1"
if [[ -z "$bin_path" || ( ! -e "$bin_path" && ! -L "$bin_path" ) ]]; then
return 1
fi
local npm_bin=""
npm_bin="$(npm_global_bin_dir 2>/dev/null || true)"
if [[ -n "$npm_bin" && "$bin_path" != "$npm_bin/openaeon" ]]; then
case "$bin_path" in
"/opt/homebrew/bin/openaeon"|"/usr/local/bin/openaeon")
;;
*)
return 1
;;
esac
fi
if [[ -L "$bin_path" ]]; then
local target=""
target="$(readlink "$bin_path" 2>/dev/null || true)"
if [[ "$target" == *"/node_modules/openaeon/"* ]]; then
rm -f "$bin_path"
ui_info "Removed stale openaeon symlink at ${bin_path}"
return 0
fi
return 1
fi
local backup=""
backup="${bin_path}.bak-$(date +%Y%m%d-%H%M%S)"
if mv "$bin_path" "$backup"; then
ui_info "Moved existing openaeon binary to ${backup}"
return 0
fi
return 1
}
npm_log_indicates_missing_build_tools() {
local log="$1"
if [[ -z "$log" || ! -f "$log" ]]; then
return 1
fi
grep -Eiq "(not found: make|make: command not found|cmake: command not found|CMAKE_MAKE_PROGRAM is not set|Could not find CMAKE|gyp ERR! find Python|no developer tools were found|is not able to compile a simple test program|Failed to build llama\\.cpp|It seems that \"make\" is not installed in your system|It seems that the used \"cmake\" doesn't work properly)" "$log"
}
install_build_tools_linux() {
require_sudo
if command -v apt-get &> /dev/null; then
if is_root; then
run_quiet_step "Updating package index" apt-get update -qq
run_quiet_step "Installing build tools" apt-get install -y -qq build-essential python3 make g++ cmake
else
run_quiet_step "Updating package index" sudo apt-get update -qq
run_quiet_step "Installing build tools" sudo apt-get install -y -qq build-essential python3 make g++ cmake
fi
return 0
fi
if command -v dnf &> /dev/null; then
if is_root; then
run_quiet_step "Installing build tools" dnf install -y -q gcc gcc-c++ make cmake python3
else
run_quiet_step "Installing build tools" sudo dnf install -y -q gcc gcc-c++ make cmake python3
fi
return 0
fi
if command -v yum &> /dev/null; then
if is_root; then
run_quiet_step "Installing build tools" yum install -y -q gcc gcc-c++ make cmake python3
else
run_quiet_step "Installing build tools" sudo yum install -y -q gcc gcc-c++ make cmake python3
fi
return 0
fi
if command -v apk &> /dev/null; then
if is_root; then
run_quiet_step "Installing build tools" apk add --no-cache build-base python3 cmake
else
run_quiet_step "Installing build tools" sudo apk add --no-cache build-base python3 cmake
fi
return 0
fi
ui_warn "Could not detect package manager for auto-installing build tools"
return 1
}
install_build_tools_macos() {
local ok=true
if ! xcode-select -p >/dev/null 2>&1; then
ui_info "Installing Xcode Command Line Tools (required for make/clang)"
xcode-select --install >/dev/null 2>&1 || true
if ! xcode-select -p >/dev/null 2>&1; then
ui_warn "Xcode Command Line Tools are not ready yet"
ui_info "Complete the installer dialog, then re-run this installer"
ok=false
fi
fi
if ! command -v cmake >/dev/null 2>&1; then
if command -v brew >/dev/null 2>&1; then
run_quiet_step "Installing cmake" brew install cmake
else
ui_warn "Homebrew not available; cannot auto-install cmake"
ok=false
fi
fi
if ! command -v make >/dev/null 2>&1; then
ui_warn "make is still unavailable"
ok=false
fi
if ! command -v cmake >/dev/null 2>&1; then
ui_warn "cmake is still unavailable"
ok=false
fi
[[ "$ok" == "true" ]]
}
auto_install_build_tools_for_npm_failure() {
local log="$1"
if ! npm_log_indicates_missing_build_tools "$log"; then
return 1
fi
ui_warn "Detected missing native build tools; attempting automatic setup"
if [[ "$OS" == "linux" ]]; then
install_build_tools_linux || return 1
elif [[ "$OS" == "macos" ]]; then
install_build_tools_macos || return 1
else
return 1
fi
ui_success "Build tools setup complete"
return 0
}
run_npm_global_install() {
local spec="$1"
local log="$2"
local -a cmd
cmd=(env "SHARP_IGNORE_GLOBAL_LIBVIPS=$SHARP_IGNORE_GLOBAL_LIBVIPS" npm --loglevel "$NPM_LOGLEVEL")
if [[ -n "$NPM_SILENT_FLAG" ]]; then
cmd+=("$NPM_SILENT_FLAG")
fi
cmd+=(--no-fund --no-audit install -g "$spec")
local cmd_display=""
printf -v cmd_display '%q ' "${cmd[@]}"
LAST_NPM_INSTALL_CMD="${cmd_display% }"
if [[ "$VERBOSE" == "1" ]]; then
"${cmd[@]}" 2>&1 | tee "$log"
return $?
fi
if [[ -n "$GUM" ]] && gum_is_tty; then
local cmd_quoted=""
local log_quoted=""
printf -v cmd_quoted '%q ' "${cmd[@]}"
printf -v log_quoted '%q' "$log"
run_with_spinner "Installing OpenAEON package" bash -c "${cmd_quoted}>${log_quoted} 2>&1"
return $?
fi
"${cmd[@]}" >"$log" 2>&1
}
extract_npm_debug_log_path() {
local log="$1"
local path=""
path="$(sed -n -E 's/.*A complete log of this run can be found in:[[:space:]]*//p' "$log" | tail -n1)"
if [[ -n "$path" ]]; then
echo "$path"
return 0
fi
path="$(grep -Eo '/[^[:space:]]+_logs/[^[:space:]]+debug[^[:space:]]*\.log' "$log" | tail -n1 || true)"
if [[ -n "$path" ]]; then
echo "$path"
return 0
fi
return 1
}
extract_first_npm_error_line() {
local log="$1"
grep -E 'npm (ERR!|error)|ERR!' "$log" | head -n1 || true
}
extract_npm_error_code() {
local log="$1"
sed -n -E 's/^npm (ERR!|error) code[[:space:]]+([^[:space:]]+).*$/\2/p' "$log" | head -n1
}
extract_npm_error_syscall() {
local log="$1"
sed -n -E 's/^npm (ERR!|error) syscall[[:space:]]+(.+)$/\2/p' "$log" | head -n1
}
extract_npm_error_errno() {
local log="$1"
sed -n -E 's/^npm (ERR!|error) errno[[:space:]]+(.+)$/\2/p' "$log" | head -n1
}
print_npm_failure_diagnostics() {
local spec="$1"
local log="$2"
local debug_log=""
local first_error=""
local error_code=""
local error_syscall=""
local error_errno=""
ui_warn "npm install failed for ${spec}"
if [[ -n "${LAST_NPM_INSTALL_CMD}" ]]; then
echo " Command: ${LAST_NPM_INSTALL_CMD}"
fi
echo " Installer log: ${log}"
error_code="$(extract_npm_error_code "$log")"
if [[ -n "$error_code" ]]; then
echo " npm code: ${error_code}"
fi
error_syscall="$(extract_npm_error_syscall "$log")"
if [[ -n "$error_syscall" ]]; then
echo " npm syscall: ${error_syscall}"
fi
error_errno="$(extract_npm_error_errno "$log")"
if [[ -n "$error_errno" ]]; then
echo " npm errno: ${error_errno}"
fi
debug_log="$(extract_npm_debug_log_path "$log" || true)"
if [[ -n "$debug_log" ]]; then
echo " npm debug log: ${debug_log}"
fi
first_error="$(extract_first_npm_error_line "$log")"
if [[ -n "$first_error" ]]; then
echo " First npm error: ${first_error}"
fi
}
install_openaeon_npm() {
local spec="$1"
local log
log="$(mktempfile)"
if ! run_npm_global_install "$spec" "$log"; then
local attempted_build_tool_fix=false
if auto_install_build_tools_for_npm_failure "$log"; then
attempted_build_tool_fix=true
ui_info "Retrying npm install after build tools setup"
if run_npm_global_install "$spec" "$log"; then
ui_success "OpenAEON npm package installed"
return 0
fi
fi
print_npm_failure_diagnostics "$spec" "$log"
if [[ "$VERBOSE" != "1" ]]; then
if [[ "$attempted_build_tool_fix" == "true" ]]; then
ui_warn "npm install still failed after build tools setup; showing last log lines"
else
ui_warn "npm install failed; showing last log lines"
fi
tail -n 80 "$log" >&2 || true
fi
if grep -q "ENOTEMPTY: directory not empty, rename .*openaeon" "$log"; then
ui_warn "npm left stale directory; cleaning and retrying"
cleanup_npm_openaeon_paths
if run_npm_global_install "$spec" "$log"; then
ui_success "OpenAEON npm package installed"
return 0
fi
return 1
fi
if grep -q "EEXIST" "$log"; then
local conflict=""
conflict="$(extract_openaeon_conflict_path "$log" || true)"
if [[ -n "$conflict" ]] && cleanup_openaeon_bin_conflict "$conflict"; then
if run_npm_global_install "$spec" "$log"; then
ui_success "OpenAEON npm package installed"
return 0
fi
return 1
fi
ui_error "npm failed because an openaeon binary already exists"
if [[ -n "$conflict" ]]; then
ui_info "Remove or move ${conflict}, then retry"
fi
ui_info "Or rerun with: npm install -g --force ${spec}"
fi
return 1
fi
ui_success "OpenAEON npm package installed"
return 0
}
TAGLINES=()
TAGLINES+=("Your terminal just grew claws—type something and let the bot pinch the busywork.")
TAGLINES+=("Welcome to the command line: where dreams 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+=("Pairing codes exist because even bots believe in consent—and good security hygiene.")
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+=("I'm not saying your workflow is chaotic... I'm just bringing a linter and a helmet.")
TAGLINES+=("Type the command with confidence—nature will provide the stack trace if needed.")
TAGLINES+=("I don't judge, but your missing API keys are absolutely judging you.")
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+=("I keep secrets like a vault... unless you print them in debug logs again.")
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+=("If you're lost, run doctor; if you're brave, run prod; if you're wise, run tests.")
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+=("Give me a workspace and I'll give you fewer tabs, fewer toggles, and more oxygen.")
TAGLINES+=("I read logs so you can keep pretending you don't have to.")
TAGLINES+=("If something's on fire, I can't extinguish it—but I can write a beautiful postmortem.")
TAGLINES+=("I'll refactor your busywork like it owes me money.")
TAGLINES+=("Say \"stop\" and I'll stop—say \"ship\" and we'll both learn a lesson.")
TAGLINES+=("I'm the reason your shell history looks like a hacker-movie montage.")
TAGLINES+=("I'm like tmux: confusing at first, then suddenly you can't live without me.")
TAGLINES+=("I can run local, remote, or purely on vibes—results may vary with DNS.")
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+=("I don't just autocomplete—I auto-commit (emotionally), then ask you to review (logically).")
TAGLINES+=("Less clicking, more shipping, fewer \"where did that file go\" moments.")
TAGLINES+=("Claws out, commit in—let's ship something mildly responsible.")
TAGLINES+=("I'll butter your workflow like a lobster roll: messy, delicious, effective.")
TAGLINES+=("Shell yeah—I'm here to pinch the toil and leave you the glory.")
TAGLINES+=("If it's repetitive, I'll automate it; if it's hard, I'll bring jokes and a rollback plan.")
TAGLINES+=("Because texting yourself reminders is so 2024.")
TAGLINES+=("WhatsApp, but make it ✨engineering✨.")
TAGLINES+=("Turning \"I'll reply later\" into \"my bot replied instantly\".")
TAGLINES+=("The only crab in your contacts you actually want to hear from. 🦞")
TAGLINES+=("Chat automation for people who peaked at IRC.")
TAGLINES+=("Because Siri wasn't answering at 3AM.")
TAGLINES+=("IPC, but it's your phone.")
TAGLINES+=("The UNIX philosophy meets your DMs.")
TAGLINES+=("curl for conversations.")
TAGLINES+=("WhatsApp Business, but without the business.")
TAGLINES+=("Meta wishes they shipped this fast.")
TAGLINES+=("End-to-end encrypted, Zuck-to-Zuck excluded.")
TAGLINES+=("The only bot Mark can't train on your DMs.")
TAGLINES+=("WhatsApp automation without the \"please accept our new privacy policy\".")
TAGLINES+=("Chat APIs that don't require a Senate hearing.")
TAGLINES+=("Because Threads wasn't the answer either.")
TAGLINES+=("Your messages, your servers, Meta's tears.")
TAGLINES+=("iMessage green bubble energy, but for everyone.")
TAGLINES+=("Siri's competent cousin.")
TAGLINES+=("Works on Android. Crazy concept, we know.")
TAGLINES+=("No \$999 stand required.")
TAGLINES+=("We ship features faster than Apple ships calculator updates.")
TAGLINES+=("Your AI assistant, now without the \$3,499 headset.")
TAGLINES+=("Think different. Actually think.")
TAGLINES+=("Ah, the fruit tree company! 🍎")
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 claw-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 a bot 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
}
map_legacy_env() {
local key="$1"
local legacy="$2"
if [[ -z "${!key:-}" && -n "${!legacy:-}" ]]; then
printf -v "$key" '%s' "${!legacy}"
fi
}
map_legacy_env "OPENAEON_TAGLINE_INDEX" "AEONPROPHET_TAGLINE_INDEX"
map_legacy_env "OPENAEON_NO_ONBOARD" "AEONPROPHET_NO_ONBOARD"
map_legacy_env "OPENAEON_NO_PROMPT" "AEONPROPHET_NO_PROMPT"
map_legacy_env "OPENAEON_DRY_RUN" "AEONPROPHET_DRY_RUN"
map_legacy_env "OPENAEON_INSTALL_METHOD" "AEONPROPHET_INSTALL_METHOD"
map_legacy_env "OPENAEON_VERSION" "AEONPROPHET_VERSION"
map_legacy_env "OPENAEON_BETA" "AEONPROPHET_BETA"
map_legacy_env "OPENAEON_GIT_DIR" "AEONPROPHET_GIT_DIR"
map_legacy_env "OPENAEON_GIT_UPDATE" "AEONPROPHET_GIT_UPDATE"
map_legacy_env "OPENAEON_NPM_LOGLEVEL" "AEONPROPHET_NPM_LOGLEVEL"
map_legacy_env "OPENAEON_VERBOSE" "AEONPROPHET_VERBOSE"
map_legacy_env "OPENAEON_PROFILE" "AEONPROPHET_PROFILE"
map_legacy_env "OPENAEON_INSTALL_SH_NO_RUN" "AEONPROPHET_INSTALL_SH_NO_RUN"
pick_tagline() {
append_holiday_taglines
local count=${#TAGLINES[@]}
if [[ "$count" -eq 0 ]]; then
echo "$DEFAULT_TAGLINE"
return
fi
if [[ -n "${OPENAEON_TAGLINE_INDEX:-}" ]]; then
if [[ "${OPENAEON_TAGLINE_INDEX}" =~ ^[0-9]+$ ]]; then
local idx=$((OPENAEON_TAGLINE_INDEX % count))
echo "${TAGLINES[$idx]}"
return
fi
fi
local idx=$((RANDOM % count))
echo "${TAGLINES[$idx]}"
}
TAGLINE=$(pick_tagline)
NO_ONBOARD=${OPENAEON_NO_ONBOARD:-0}
NO_PROMPT=${OPENAEON_NO_PROMPT:-0}
DRY_RUN=${OPENAEON_DRY_RUN:-0}
INSTALL_METHOD=${OPENAEON_INSTALL_METHOD:-}
OPENAEON_VERSION=${OPENAEON_VERSION:-latest}
USE_BETA=${OPENAEON_BETA:-0}
GIT_DIR_DEFAULT="${HOME}/openaeon"
GIT_DIR=${OPENAEON_GIT_DIR:-$GIT_DIR_DEFAULT}
GIT_UPDATE=${OPENAEON_GIT_UPDATE:-1}
SHARP_IGNORE_GLOBAL_LIBVIPS="${SHARP_IGNORE_GLOBAL_LIBVIPS:-1}"
NPM_LOGLEVEL="${OPENAEON_NPM_LOGLEVEL:-error}"
NPM_SILENT_FLAG="--silent"
VERBOSE="${OPENAEON_VERBOSE:-0}"
OPENAEON_BIN=""
PNPM_CMD=()
HELP=0
print_usage() {
cat <<EOF
OpenAEON installer (macOS + Linux)
Usage:
curl -fsSL --proto '=https' --tlsv1.2 https://raw.githubusercontent.com/openaeon/OpenAEON/main/install.sh | bash -s -- [options]
Options:
--install-method, --method npm|git Install via npm (default) or from a git checkout
--npm Shortcut for --install-method npm
--git, --github Shortcut for --install-method git
--version <version|dist-tag> npm install: version (default: latest)
--beta Use beta if available, else latest
--git-dir, --dir <path> Checkout directory (default: ~/openaeon)
--no-git-update Skip git pull for existing checkout
--no-onboard Skip onboarding (non-interactive)
--no-prompt Disable prompts (required in CI/automation)
--dry-run Print what would happen (no changes)
--verbose Print debug output (set -x, npm verbose)
--help, -h Show this help
Environment variables:
OPENAEON_INSTALL_METHOD=git|npm
OPENAEON_VERSION=latest|next|<semver>
OPENAEON_BETA=0|1
OPENAEON_GIT_DIR=...
OPENAEON_GIT_UPDATE=0|1
OPENAEON_NO_PROMPT=1
OPENAEON_DRY_RUN=1
OPENAEON_NO_ONBOARD=1
OPENAEON_VERBOSE=1
OPENAEON_NPM_LOGLEVEL=error|warn|notice Default: error (hide npm deprecation noise)
SHARP_IGNORE_GLOBAL_LIBVIPS=0|1 Default: 1 (avoid sharp building against global libvips)
Examples:
curl -fsSL --proto '=https' --tlsv1.2 https://raw.githubusercontent.com/openaeon/OpenAEON/main/install.sh | bash