Repository navigation
Expand file tree
/
Copy pathinstall
More file actions
executable file
·3332 lines (2988 loc) · 147 KB
/
Copy pathinstall
File metadata and controls
executable file
·3332 lines (2988 loc) · 147 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
#!/usr/bin/env bash
set -euo pipefail
APP=iris
MUTED='\033[0;2m'
RED='\033[0;31m'
ORANGE='\033[38;5;214m'
CYAN='\033[0;36m'
GREEN='\033[0;32m'
NC='\033[0m' # No Color
usage() {
cat <<EOF
IRIS Installer — CLI, SDK, Desktop App, Bridge, Docker Sandbox, Remotion
Usage: install [options]
Installs:
1. IRIS CLI — AI coding agent (terminal)
2. IRIS SDK — CLI tools & PHP SDK
3. IRIS App — Desktop application (macOS)
4. MCP Config — Agent tool integration (scaffolded for future use)
5. Agent Bridge — Hive compute node + session bridge
6. Docker Sandbox — Sandboxed container for AI agent development
7. Remotion — Video & image generation compositions (lazy-installed)
Options:
-h, --help Display this help message
-v, --version <version> Install a specific IRIS CLI version (see the releases page)
-b, --binary <path> Install IRIS CLI from a local binary
--no-modify-path Don't modify shell config files (.zshrc, .bashrc, etc.)
--skip-sdk Skip SDK/CLI installation
--skip-app Skip desktop app installation
--skip-mcp Skip MCP config scaffolding
--skip-bridge Skip Coding Agent Bridge installation
--skip-sandbox Skip Docker Sandbox installation
--skip-remotion Skip Remotion video framework installation
--api-url <url> Set IRIS API URL (default: https://freelabel.net)
--token <token> Pre-seed SDK token (skip interactive auth). On Linux this also makes the
machine a Hive node: systemd unit, first heartbeat, then success.
Or set IRIS_SDK_TOKEN in the environment to keep it out of argv.
--user-id <id> Pre-seed user ID (used with --token)
--only-code Only install IRIS CLI (skip SDK, app, MCP, bridge, sandbox)
Examples:
curl -fsSL https://heyiris.io/install-code | bash
curl -fsSL https://heyiris.io/install-code | bash -s -- --version <version>
curl -fsSL https://heyiris.io/install-code | bash -s -- --only-code
curl -fsSL https://heyiris.io/install-code | bash -s -- --skip-app
curl -fsSL https://heyiris.io/install-code | bash -s -- --api-url https://custom.example.com
curl -fsSL https://heyiris.io/install-code | bash -s -- --token api_token_xxx --user-id 42
curl -fsSL https://heyiris.io/install-code | IRIS_SDK_TOKEN=api_token_xxx bash
EOF
}
# ─── Install beacon (#179077) ─────────────────────────────────────────────────
# Anonymous, metadata-only, fire-and-forget. Nothing about an install ATTEMPT
# reached us before this: the CLI beacon needs a token, and there is no token
# until after iris-login — which happens after the install. So a failed install
# looked exactly like nobody trying.
#
# Never blocks (3s timeout, backgrounded) and never fails the install — the `||
# true` is load-bearing under `set -e`. Opt out with IRIS_TELEMETRY=0.
IRIS_BEACON_URL="https://heyiris.io/api/v6/telemetry/install"
IRIS_INSTALLER_VERSION="2026-08-06"
send_install_beacon() {
case "${IRIS_TELEMETRY:-}" in 0|off|false) return 0 ;; esac
command -v curl >/dev/null 2>&1 || return 0
local event_type="$1" step="${2:-}" reason="${3:-}"
local os arch has_git has_node
os=$(uname -s 2>/dev/null | tr '[:upper:]' '[:lower:]')
arch=$(uname -m 2>/dev/null)
has_git=$(command -v git >/dev/null 2>&1 && echo true || echo false)
has_node=$(command -v node >/dev/null 2>&1 && echo true || echo false)
# Metadata only — no paths, no hostname, no username.
local payload
payload=$(printf '{"event_type":"%s","os":"%s","arch":"%s","installer_version":"%s","shell":"bash","has_git":%s,"has_node":%s,"step":"%s","reason":"%s"}' \
"$event_type" "$os" "$arch" "$IRIS_INSTALLER_VERSION" "$has_git" "$has_node" "$step" "$(printf '%s' "$reason" | tr -d '"\\' | cut -c1-200)")
(curl -fsS -m 3 -X POST -H 'Content-Type: application/json' -d "$payload" "$IRIS_BEACON_URL" >/dev/null 2>&1 &) || true
return 0
}
requested_version=${VERSION:-}
no_modify_path=false
binary_path=""
skip_sdk=false
skip_app=false
skip_mcp=false
skip_agents_md=false
only_docs_mode=false
skip_bridge=false
skip_sandbox=false
skip_remotion=false
iris_api_url="https://freelabel.net"
pre_token="${IRIS_SDK_TOKEN:-}"
pre_user_id="${IRIS_USER_ID:-}"
while [[ $# -gt 0 ]]; do
case "$1" in
-h|--help)
usage
exit 0
;;
-v|--version)
if [[ -n "${2:-}" ]]; then
requested_version="$2"
shift 2
else
echo -e "${RED}Error: --version requires a version argument${NC}"
exit 1
fi
;;
-b|--binary)
if [[ -n "${2:-}" ]]; then
binary_path="$2"
shift 2
else
echo -e "${RED}Error: --binary requires a path argument${NC}"
exit 1
fi
;;
--no-modify-path)
no_modify_path=true
shift
;;
--skip-sdk)
skip_sdk=true
shift
;;
--skip-app)
skip_app=true
shift
;;
--skip-mcp)
skip_mcp=true
shift
;;
--skip-agents-md)
skip_agents_md=true
shift
;;
--skip-bridge)
skip_bridge=true
shift
;;
--skip-sandbox)
skip_sandbox=true
shift
;;
--skip-remotion)
skip_remotion=true
shift
;;
--api-url)
if [[ -n "${2:-}" ]]; then
iris_api_url="$2"
shift 2
else
echo -e "${RED}Error: --api-url requires a URL argument${NC}"
exit 1
fi
;;
--token)
if [[ -n "${2:-}" ]]; then
pre_token="$2"
shift 2
else
echo -e "${RED}Error: --token requires a token argument${NC}"
exit 1
fi
;;
--user-id)
if [[ -n "${2:-}" ]]; then
pre_user_id="$2"
shift 2
else
echo -e "${RED}Error: --user-id requires an ID argument${NC}"
exit 1
fi
;;
--only-code)
skip_sdk=true
skip_app=true
skip_mcp=true
skip_agents_md=true
skip_bridge=true
skip_sandbox=true
skip_remotion=true
shift
;;
--only-docs)
# Re-fetch the IRIS scaffold (AGENTS.md + how-to/ recipes) only.
# Use this to update docs without reinstalling the binary.
skip_sdk=true
skip_app=true
skip_mcp=true
skip_agents_md=false
skip_bridge=true
skip_sandbox=true
skip_remotion=true
only_docs_mode=true
shift
;;
*)
echo -e "${ORANGE}Warning: Unknown option '$1'${NC}" >&2
shift
;;
esac
done
# Validate --api-url is a proper URL (prevents injection into docker-compose YAML)
if ! [[ "$iris_api_url" =~ ^https?://[a-zA-Z0-9._-]+(:[0-9]+)?(/.*)?$ ]]; then
echo -e "${RED}Error: --api-url must be a valid HTTP(S) URL${NC}"
exit 1
fi
# Linux package installs below run under sudo. With a token the run is unattended (#192964 R3:
# one command, nothing typed after it), so sudo must fail rather than stop to ask for a password.
# As root, no sudo at all: a minimal image may not have it.
pkg_sudo() {
if [ "$(id -u)" = "0" ]; then "$@"
elif [ -n "$pre_token" ]; then sudo -n "$@"
else sudo "$@"
fi
}
# ─── Pre-flight: verify required utilities ────────────────────────────────────
_missing_required=""
for _cmd in curl grep sed mktemp chmod mkdir; do
command -v "$_cmd" >/dev/null 2>&1 || _missing_required="$_missing_required $_cmd"
done
if [ -n "$_missing_required" ]; then
echo -e "${RED}Missing required utilities:${NC}$_missing_required"
echo -e "${MUTED}These are usually built into your OS. On macOS, try running ${NC}xcode-select --install"
echo -e "${MUTED}On Linux: ${NC}sudo apt install coreutils curl"
exit 1
fi
# macOS version check — the IRIS binary is compiled with Bun and uses
# LC_DYLD_CHAINED_FIXUPS (load command 0x80000034) for faster startup.
# This load command was introduced in macOS 12 (Monterey). Older macOS
# versions will install successfully but crash at runtime with:
# dyld: cannot load 'iris' (load command 0x80000034 is unknown)
# Abort trap: 6
# Detect this BEFORE downloading so the user gets a clear explanation.
if [ "$(uname -s)" = "Darwin" ]; then
_macos_version=$(sw_vers -productVersion 2>/dev/null || echo "")
_macos_major=$(echo "$_macos_version" | cut -d. -f1)
if [ -n "$_macos_major" ] && [ "$_macos_major" -lt 12 ] 2>/dev/null; then
echo -e "${RED}════════════════════════════════════════════════════════════════${NC}"
echo -e "${RED} ⚠ macOS Version Warning${NC}"
echo -e "${RED}════════════════════════════════════════════════════════════════${NC}"
echo -e "${ORANGE}Your macOS version:${NC} $_macos_version"
echo -e "${ORANGE}IRIS CLI requires:${NC} macOS 12 (Monterey) or later"
echo -e ""
echo -e "${MUTED}The binary will install and authenticate, but will fail to${NC}"
echo -e "${MUTED}run with this error:${NC}"
echo -e "${MUTED} ${NC}dyld: cannot load 'iris' (load command 0x80000034 is unknown)"
echo -e "${MUTED} ${NC}Abort trap: 6"
echo -e ""
echo -e "${MUTED}This is because IRIS is compiled with Bun, which uses Mach-O${NC}"
echo -e "${MUTED}features only available on macOS 12 and later.${NC}"
echo -e ""
echo -e "${MUTED}Options:${NC}"
echo -e "${MUTED} 1. Upgrade macOS:${NC} https://support.apple.com/macos/upgrade"
echo -e "${MUTED} 2. Report the issue:${NC} https://github.com/FREELABEL/iris-opencode/issues"
echo -e "${RED}════════════════════════════════════════════════════════════════${NC}"
echo -e ""
echo -e "${MUTED}Continuing install anyway in 5 seconds (Ctrl-C to abort)...${NC}"
sleep 5
fi
fi
# ─── Dependency bootstrap ────────────────────────────────────────────────────
# MUST run before every dep check below. The unzip pre-flight, the tmux check,
# install_bridge and install_remotion all branch on `command -v brew|node`, so
# bootstrapping Homebrew at the END of this script (where it used to live) meant
# a clean macOS box silently skipped the daemon, the bridge and Remotion.
# Can we reach the terminal even though stdin is the curl pipe?
IRIS_TTY=false
if [ -e /dev/tty ] && (echo "" > /dev/tty) 2>/dev/null; then
IRIS_TTY=true
fi
# Pick up an installed-but-unshimmed brew (common on fresh Apple Silicon)
if ! command -v brew >/dev/null 2>&1; then
for _brew_path in /opt/homebrew/bin/brew /usr/local/bin/brew /home/linuxbrew/.linuxbrew/bin/brew; do
if [ -x "$_brew_path" ]; then eval "$("$_brew_path" shellenv)" || true; break; fi
done
fi
if [ "$(uname)" = "Darwin" ] && ! command -v brew >/dev/null 2>&1; then
echo -e "${CYAN}→${NC} Installing Homebrew (needed for tmux, Node.js and the Hive daemon)..."
if [ "$IRIS_TTY" = "true" ]; then
# Read the sudo password from the terminal, NOT the curl pipe. Without
# this redirect Homebrew aborts with "stdin is not a TTY".
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" < /dev/tty || true
else
# No terminal at all — use Homebrew's own non-interactive mode. Needs
# passwordless sudo; degrade gracefully rather than aborting the install.
NONINTERACTIVE=1 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" || true
fi
for _brew_path in /opt/homebrew/bin/brew /usr/local/bin/brew; do
if [ -x "$_brew_path" ]; then eval "$("$_brew_path" shellenv)" || true; break; fi
done
if command -v brew >/dev/null 2>&1; then
echo -e "${GREEN}✓${NC} Homebrew installed"
else
echo -e "${ORANGE}⚠${NC} Homebrew install failed — tmux, Node.js and the daemon will be skipped."
echo -e "${MUTED} Install it from https://brew.sh, then re-run this installer.${NC}"
fi
fi
# Node.js — required by install_bridge (Agent Bridge + Hive daemon) and
# install_remotion, both of which run long before the old end-of-script block.
if ! command -v node >/dev/null 2>&1; then
echo -e "${CYAN}→${NC} Installing Node.js (required by the Agent Bridge and Remotion)..."
if command -v brew >/dev/null 2>&1; then
brew install node >/dev/null 2>&1 || true
elif command -v apt-get >/dev/null 2>&1; then
pkg_sudo apt-get install -y nodejs npm >/dev/null 2>&1 || true
elif command -v dnf >/dev/null 2>&1; then
pkg_sudo dnf install -y nodejs npm >/dev/null 2>&1 || true
fi
if command -v node >/dev/null 2>&1; then
echo -e "${GREEN}✓${NC} Node.js installed: $(node -v 2>/dev/null || echo unknown)"
else
echo -e "${ORANGE}⚠${NC} Node.js unavailable — Agent Bridge and Remotion will be skipped."
echo -e "${MUTED} Install it from https://nodejs.org, then re-run this installer.${NC}"
fi
fi
# Soft pre-flight: warn (don't exit) about commands the binary install needs
_missing_soft=""
for _cmd in unzip; do
command -v "$_cmd" >/dev/null 2>&1 || _missing_soft="$_missing_soft $_cmd"
done
if [ -n "$_missing_soft" ]; then
echo -e "${ORANGE}Warning:${NC} missing soft dependencies:$_missing_soft"
echo -e "${MUTED}The IRIS installer needs these to extract the binary. Attempting auto-install...${NC}"
if command -v brew >/dev/null 2>&1; then
for _pkg in $_missing_soft; do brew install "$_pkg" >/dev/null 2>&1 || true; done
elif command -v apt-get >/dev/null 2>&1; then
pkg_sudo apt-get install -y $_missing_soft >/dev/null 2>&1 || true
else
echo -e "${ORANGE}Could not auto-install. Please install manually:${NC}$_missing_soft"
echo -e "${MUTED}On macOS without Homebrew, first run:${NC}"
echo -e " /bin/bash -c \"\$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)\""
echo -e "${MUTED}Then re-run this installer.${NC}"
exit 1
fi
# Re-check
for _cmd in $_missing_soft; do
if ! command -v "$_cmd" >/dev/null 2>&1; then
echo -e "${RED}Auto-install of $_cmd failed.${NC} Please install it manually and re-run."
exit 1
fi
done
echo -e "${GREEN}✓${NC} Auto-installed:$_missing_soft"
fi
# ─── tmux (required for Hive session persistence) ─────────────────────────
if ! command -v tmux >/dev/null 2>&1; then
echo -e "${MUTED}Installing tmux (required for Hive compute sessions)...${NC}"
if command -v brew >/dev/null 2>&1; then
# `|| true` matters: set -e is on, so a failed brew install would
# otherwise abort the whole installer here.
brew install tmux >/dev/null 2>&1 || true
elif command -v apt-get >/dev/null 2>&1; then
pkg_sudo apt-get install -y tmux >/dev/null 2>&1 || true
elif command -v dnf >/dev/null 2>&1; then
pkg_sudo dnf install -y tmux >/dev/null 2>&1 || true
elif command -v pacman >/dev/null 2>&1; then
pkg_sudo pacman -S --noconfirm tmux >/dev/null 2>&1 || true
else
echo -e "${ORANGE}Could not auto-install tmux.${NC}"
echo -e "${MUTED}Install manually: brew install tmux (macOS) or sudo apt install tmux (Linux)${NC}"
echo -e "${MUTED}The IRIS Hive daemon requires tmux for session persistence.${NC}"
fi
if command -v tmux >/dev/null 2>&1; then
echo -e "${GREEN}✓${NC} tmux installed: $(tmux -V 2>/dev/null || echo 'unknown version')"
fi
else
# Version check — require tmux >= 3.0 for wait-for support
_tmux_ver=$(tmux -V 2>/dev/null | grep -oE '[0-9]+\.[0-9]+' | head -1)
_tmux_major=$(echo "$_tmux_ver" | cut -d. -f1)
if [ -n "$_tmux_major" ] && [ "$_tmux_major" -lt 3 ] 2>/dev/null; then
echo -e "${ORANGE}tmux $_tmux_ver found but 3.0+ recommended for full Hive features.${NC}"
echo -e "${MUTED}Upgrade: brew install tmux (macOS) or sudo apt install tmux (Linux)${NC}"
fi
fi
INSTALL_DIR=$HOME/.iris/bin
mkdir -p "$INSTALL_DIR"
# Platform detection runs UNCONDITIONALLY, before the --binary branch.
#
# It used to live inside the `else` below — i.e. only on the download path. The desktop app
# installs the CLI from its BUNDLED sidecar, so it always passes --binary, always took the
# `if` branch, and never set os/arch. The tmux and Node sections further down then hit
# `node-v$NODE_VERSION-$os-$arch` under `set -u` and died with:
#
# line 461: os: unbound variable
#
# So the app's install path was broken 100% of the time while the curl-pipe path was fine —
# and a bare-machine test of the curl path passes cleanly right next to it. Detection is
# cheap, has no side effects, and every later section wants it, so it belongs out here where
# both branches get it. (Originally 1afe66dc77; re-applied after this file was restored, because
# a wholesale restore drops it exactly the way the wholesale replacement dropped the funnel.)
raw_os=$(uname -s)
os=$(echo "$raw_os" | tr '[:upper:]' '[:lower:]')
case "$raw_os" in
Darwin*) os="darwin" ;;
Linux*) os="linux" ;;
MINGW*|MSYS*|CYGWIN*) os="windows" ;;
esac
arch=$(uname -m)
if [[ "$arch" == "aarch64" ]]; then
arch="arm64"
fi
if [[ "$arch" == "x86_64" ]]; then
arch="x64"
fi
if [ "$os" = "darwin" ] && [ "$arch" = "x64" ]; then
rosetta_flag=$(sysctl -n sysctl.proc_translated 2>/dev/null || echo 0)
if [ "$rosetta_flag" = "1" ]; then
arch="arm64"
fi
fi
# If --binary is provided, skip all download/detection logic
if [ -n "$binary_path" ]; then
if [ ! -f "$binary_path" ]; then
echo -e "${RED}Error: Binary not found at ${binary_path}${NC}"
exit 1
fi
specific_version="local"
else
combo="$os-$arch"
case "$combo" in
linux-x64|linux-arm64|darwin-x64|darwin-arm64|windows-x64)
;;
*)
echo -e "${RED}Unsupported OS/Arch: $os/$arch${NC}"
echo -e "${MUTED}Supported: linux-x64, linux-arm64, darwin-x64, darwin-arm64, windows-x64${NC}"
exit 1
;;
esac
archive_ext=".zip"
if [ "$os" = "linux" ]; then
archive_ext=".tar.gz"
fi
is_musl=false
if [ "$os" = "linux" ]; then
if [ -f /etc/alpine-release ]; then
is_musl=true
fi
if command -v ldd >/dev/null 2>&1; then
if ldd --version 2>&1 | grep -qi musl; then
is_musl=true
fi
fi
fi
needs_baseline=false
if [ "$arch" = "x64" ]; then
if [ "$os" = "linux" ]; then
if ! grep -qi avx2 /proc/cpuinfo 2>/dev/null; then
needs_baseline=true
fi
fi
if [ "$os" = "darwin" ]; then
# AVX2 sysctl key has changed across macOS versions. Check both
# variants and only flag as missing if BOTH return 0/missing.
avx2_a=$(sysctl -n hw.optional.avx2_0 2>/dev/null || echo 0)
avx2_b=$(sysctl -n hw.optional.avx2 2>/dev/null || echo 0)
if [ "$avx2_a" != "1" ] && [ "$avx2_b" != "1" ]; then
needs_baseline=true
fi
fi
fi
target="$os-$arch"
if [ "$needs_baseline" = "true" ]; then
target="$target-baseline"
fi
if [ "$is_musl" = "true" ]; then
target="$target-musl"
fi
filename="$APP-$target$archive_ext"
# Verify the requested asset actually exists in the GitHub release. If
# the baseline build is missing (no baseline artifacts published for this
# version), fall back to the standard build with a clear warning. This
# protects against asset-name mismatches and macOS AVX2 detection quirks
# where a Mac actually supports AVX2 but the sysctl key differs.
if [ "$needs_baseline" = "true" ] && [ -z "$requested_version" ]; then
_probe_url="https://github.com/FREELABEL/iris-opencode/releases/latest/download/$filename"
if ! curl -fsSL --head --max-time 8 "$_probe_url" >/dev/null 2>&1; then
_fallback_filename="$APP-$os-$arch$archive_ext"
if [ "$is_musl" = "true" ]; then
_fallback_filename="$APP-$os-$arch-musl$archive_ext"
fi
echo -e "${ORANGE}Warning:${NC} baseline build ($filename) not published for this release."
echo -e "${MUTED}Falling back to standard build: ${NC}$_fallback_filename"
echo -e "${MUTED}If this binary crashes with 'Illegal instruction', your CPU likely lacks AVX2.${NC}"
echo -e "${MUTED}In that case, please file an issue: ${NC}https://github.com/FREELABEL/iris-opencode/issues"
filename="$_fallback_filename"
target="$os-$arch"
[ "$is_musl" = "true" ] && target="$target-musl"
fi
fi
if [ "$os" = "linux" ]; then
if ! command -v tar >/dev/null 2>&1; then
echo -e "${RED}Error: 'tar' is required but not installed.${NC}"
echo -e "${MUTED}Install with: sudo apt install tar${NC}"
exit 1
fi
else
if ! command -v unzip >/dev/null 2>&1; then
echo -e "${RED}Error: 'unzip' is required but not installed.${NC}"
echo -e "${MUTED}Install with: brew install unzip (macOS) or sudo apt install unzip (Linux)${NC}"
exit 1
fi
fi
send_install_beacon "install_start"
if [ -z "$requested_version" ]; then
# Do NOT use /releases/latest. TWO release series share this repo — `v*` for this CLI
# and `desktop-v*` for the Tauri desktop app — and GitHub's "latest" is simply the most
# recently published NON-prerelease of either. On 2026-08-27, promoting
# desktop-v1.18.28 made /releases/latest return that tag; it has no bare `v` prefix, so
# the parse below produced an empty string and EVERY `curl | bash` install died with
# "Failed to fetch version information". The desktop app's release cadence must not be
# able to break the CLI installer.
#
# Ask for the highest release in THIS series instead. The `"v[0-9]` anchor is what
# excludes desktop-v*: after `"tag_name": "` that tag begins with `d`, not `v`.
# HIGHEST, not first-listed (#188596): GitHub lists a release by its tag's commit date, so
# v1.5.0 (the v2 engine, tagged on an older commit) sat below v1.3.355 and fresh installs
# got v1. A field-wise numeric sort, because macOS's sort has no -V on older releases.
specific_version=$(curl -s "https://api.github.com/repos/FREELABEL/iris-opencode/releases?per_page=100" \
| sed -n 's/.*"tag_name": *"v\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\)".*/\1/p' \
| sort -t. -k1,1n -k2,2n -k3,3n | tail -1) || true
if [[ -z "$specific_version" ]]; then
# Last resort: the redirect target of /releases/latest/download still resolves by
# ASSET NAME, so it can land on a valid CLI release even when the API parse failed.
specific_version=$(curl -sI "https://github.com/FREELABEL/iris-opencode/releases/latest/download/$filename" \
| sed -n 's|.*/releases/download/v\([0-9][^/]*\)/.*|\1|p' | head -1) || true
fi
url="https://github.com/FREELABEL/iris-opencode/releases/download/v${specific_version}/$filename"
if [[ -z "$specific_version" ]]; then
echo -e "${RED}Failed to fetch version information${NC}"
echo -e "${MUTED}Check your internet connection or install a specific version:${NC}"
# Do NOT name a version here. This line used to say 1.1.6 — an ancient build —
# and on 2026-08-27 a client followed it verbatim and installed that, because a
# hardcoded example in an error message reads as a recommendation. Point at the
# list instead, which cannot go stale.
echo -e "${MUTED} Pick a version from https://github.com/FREELABEL/iris-opencode/releases${NC}"
echo -e "${MUTED} curl -fsSL https://heyiris.io/install-code | bash -s -- --version <version>${NC}"
exit 1
fi
else
# Strip leading 'v' if present
requested_version="${requested_version#v}"
url="https://github.com/FREELABEL/iris-opencode/releases/download/v${requested_version}/$filename"
specific_version=$requested_version
# Verify the release exists before downloading
http_status=$(curl -sI -o /dev/null -w "%{http_code}" "https://github.com/FREELABEL/iris-opencode/releases/tag/v${requested_version}")
if [ "$http_status" = "404" ]; then
echo -e "${RED}Error: Release v${requested_version} not found${NC}"
echo -e "${MUTED}Available releases: https://github.com/FREELABEL/iris-opencode/releases${NC}"
exit 1
fi
fi
fi
print_message() {
local level=$1
local message=$2
local color=""
case $level in
info) color="${NC}" ;;
warning) color="${NC}" ;;
error) color="${RED}" ;;
esac
echo -e "${color}${message}${NC}"
}
check_version() {
if [ -f "$INSTALL_DIR/iris" ]; then
print_message info "${MUTED}Updating IRIS CLI to ${NC}$specific_version${MUTED}...${NC}"
fi
}
unbuffered_sed() {
if echo | sed -u -e "" >/dev/null 2>&1; then
sed -nu "$@"
elif echo | sed -l -e "" >/dev/null 2>&1; then
sed -nl "$@"
else
local pad="$(printf "\n%512s" "")"
sed -ne "s/$/\\${pad}/" "$@"
fi
}
print_progress() {
local bytes="$1"
local length="$2"
[ "$length" -gt 0 ] || return 0
local width=50
local percent=$(( bytes * 100 / length ))
[ "$percent" -gt 100 ] && percent=100
local on=$(( percent * width / 100 ))
local off=$(( width - on ))
local filled=$(printf "%*s" "$on" "")
filled=${filled// /■}
local empty=$(printf "%*s" "$off" "")
empty=${empty// /・}
printf "\r${ORANGE}%s%s %3d%%${NC}" "$filled" "$empty" "$percent" >&4
}
download_with_progress() {
local url="$1"
local output="$2"
if [ -t 2 ]; then
exec 4>&2
else
exec 4>/dev/null
fi
local tmp_dir=${TMPDIR:-/tmp}
local basename="${tmp_dir}/iris_install_$$"
local tracefile="${basename}.trace"
rm -f "$tracefile"
mkfifo "$tracefile"
# Hide cursor
printf "\033[?25l" >&4
trap "trap - RETURN; rm -f \"$tracefile\"; printf '\033[?25h' >&4; exec 4>&-" RETURN
(
curl --trace-ascii "$tracefile" -s -L -o "$output" "$url"
) &
local curl_pid=$!
unbuffered_sed \
-e 'y/ACDEGHLNORTV/acdeghlnortv/' \
-e '/^0000: content-length:/p' \
-e '/^<= recv data/p' \
"$tracefile" | \
{
local length=0
local bytes=0
while IFS=" " read -r -a line; do
[ "${#line[@]}" -lt 2 ] && continue
local tag="${line[0]} ${line[1]}"
if [ "$tag" = "0000: content-length:" ]; then
length="${line[2]}"
length=$(echo "$length" | tr -d '\r')
bytes=0
elif [ "$tag" = "<= recv" ]; then
local size="${line[3]}"
bytes=$(( bytes + size ))
if [ "$length" -gt 0 ]; then
print_progress "$bytes" "$length"
fi
fi
done
}
wait $curl_pid
local ret=$?
echo "" >&4
return $ret
}
download_and_install() {
print_message info "\n${MUTED}Installing ${NC}IRIS CLI ${MUTED}version: ${NC}$specific_version"
local tmp_dir
tmp_dir=$(mktemp -d "${TMPDIR:-/tmp}/iris_install_XXXXXX")
if [[ "$os" == "windows" ]] || ! [ -t 2 ]; then
# Non-TTY or Windows: use standard curl progress
curl -# -L -o "$tmp_dir/$filename" "$url"
elif ! download_with_progress "$url" "$tmp_dir/$filename"; then
# Custom progress failed — only fallback if file wasn't already downloaded
if [ ! -s "$tmp_dir/$filename" ]; then
curl -# -L -o "$tmp_dir/$filename" "$url"
fi
fi
# Verify the download succeeded and isn't an HTML error page
if [ ! -s "$tmp_dir/$filename" ]; then
echo -e "${RED}Error: Download failed — file is empty${NC}"
echo -e "${MUTED}The binary for your platform (${target}) may not be available in this release.${NC}"
echo -e "${MUTED}Check available assets: https://github.com/FREELABEL/iris-opencode/releases/tag/v${specific_version}${NC}"
rm -rf "$tmp_dir"
exit 1
fi
# Check if we got an HTML error page instead of a real binary
if head -c 15 "$tmp_dir/$filename" | grep -qi '<!doctype\|<html'; then
echo -e "${RED}Error: Download returned an error page instead of the binary${NC}"
echo -e "${MUTED}The binary for your platform (${target}) is not available in release v${specific_version}.${NC}"
echo -e "${MUTED}Check available assets: https://github.com/FREELABEL/iris-opencode/releases/tag/v${specific_version}${NC}"
rm -rf "$tmp_dir"
exit 1
fi
# Verify the download against the checksum published beside it (#185158).
#
# The two guards above catch an EMPTY file and an HTML error page. Neither can see a
# download that succeeded and is simply the wrong or altered bytes, and `set -euo
# pipefail` cannot either: it only catches what makes a tool exit non-zero. Measured
# on a deliberately undersized volume, unzip returns 50 and nothing installs -- that
# path is fine. A complete transfer of the wrong build exits 0 everywhere.
#
# Not hypothetical in this repo: the desktop app shipped its own opencode sidecar as
# `iris` for two weeks (#183738), and nothing between the release and the user asked
# what the bytes were.
#
# A MISSING checksum is reported, not silently skipped. Releases before this existed
# have none, so failing closed would break every install of an older version -- but a
# skip nobody is told about is how "verified" quietly becomes decorative. Say which
# one happened.
checksum_url="${url}.sha256"
if curl -fsSL --max-time 30 -o "$tmp_dir/$filename.sha256" "$checksum_url" 2>/dev/null \
&& [ -s "$tmp_dir/$filename.sha256" ]; then
_sum_cmd=""
if command -v sha256sum >/dev/null 2>&1; then _sum_cmd="sha256sum"
elif command -v shasum >/dev/null 2>&1; then _sum_cmd="shasum -a 256"; fi
if [ -z "$_sum_cmd" ]; then
echo -e "${ORANGE}Warning: a checksum was published but neither sha256sum nor shasum is installed.${NC}"
echo -e "${MUTED} The download was NOT verified. Install coreutils to enable this check.${NC}"
else
# The published file holds the basename, so verify from inside tmp_dir.
_want=$(cut -d" " -f1 < "$tmp_dir/$filename.sha256" | tr -d "[:space:]")
_got=$(cd "$tmp_dir" && $_sum_cmd "$filename" | cut -d" " -f1 | tr -d "[:space:]")
if [ -z "$_want" ] || [ -z "$_got" ]; then
echo -e "${RED}Error: could not compute or read a checksum (want='${_want}' got='${_got}').${NC}"
echo -e "${MUTED} Refusing to install unverified bytes. Re-run to try again.${NC}"
rm -rf "$tmp_dir"
exit 1
fi
if [ "$_want" != "$_got" ]; then
echo -e "${RED}Error: CHECKSUM MISMATCH - refusing to install.${NC}"
echo -e "${MUTED} expected ${_want}${NC}"
echo -e "${MUTED} actual ${_got}${NC}"
echo -e "${MUTED} These bytes are not the ones this release published. Do not use them.${NC}"
echo -e "${MUTED} Retry the install; if it persists, report it with the two digests above.${NC}"
rm -rf "$tmp_dir"
exit 1
fi
echo -e "${MUTED} checksum verified (sha256 ${_got})${NC}"
fi
else
echo -e "${MUTED} no checksum published for this release - integrity NOT verified${NC}"
fi
if [ "$os" = "linux" ]; then
tar -xzf "$tmp_dir/$filename" -C "$tmp_dir"
else
unzip -q "$tmp_dir/$filename" -d "$tmp_dir"
fi
mv "$tmp_dir/iris" "$INSTALL_DIR"
chmod 755 "${INSTALL_DIR}/iris"
# Ad-hoc sign on macOS so Gatekeeper doesn't SIGKILL the binary (exit 137)
if [ "$(uname -s)" = "Darwin" ] && command -v codesign >/dev/null 2>&1; then
codesign --force --deep --sign - "${INSTALL_DIR}/iris" 2>/dev/null || true
fi
rm -rf "$tmp_dir"
# Ask the path what it is now. See verify_installed_cli above for why a copy that
# exited 0 is not evidence that the product is installed.
verify_installed_cli || exit 1
}
# ─── Post-install read-back: did we install THE PRODUCT, or just a file? ──────
#
# A GREEN EXIT IS NOT A LANDING. Until 2026-09-13 nothing in this script ever ran the
# binary it had just written, so "IRIS CLI installed" was a claim about a copy operation,
# not about a working CLI. Three ways that goes wrong, none of which the old checks could
# see:
#
# 1. `codesign ... || true` above. If ad-hoc signing fails on macOS, Gatekeeper SIGKILLs
# the binary on every run (exit 137) — and the `|| true` is deliberate, so the failure
# is invisible. The user gets an `iris` that dies instantly and an installer that said
# it succeeded.
# 2. The release can serve the WRONG binary. Nothing published is checksummed (there are
# zero sha/sig assets on the release), so a complete download of the wrong build
# installs silently. This is not hypothetical: the desktop app shipped its own
# opencode sidecar as `iris` for two weeks (#183738, #184861).
# 3. `check_version()` tests `[ -f "$INSTALL_DIR/iris" ]`. A 216-module platform CLI and a
# core-only sidecar are the same answer to that question.
#
# The desktop app grew exactly this read-back in cli.rs (`cli_state()`) when the sidecar bug
# was fixed. The installer — which is what EVERY new user runs — did not get it. This closes
# that asymmetry.
#
# Matched on stdout AND stderr joined, on purpose: the real CLI prints help to stdout and
# the upstream sidecar prints it to stderr, so a stdout-only check would pass today for a
# reason unrelated to what is being asked.
verify_installed_cli() {
local bin="${INSTALL_DIR}/iris"
if [ ! -x "$bin" ]; then
echo -e "${RED}Install failed:${NC} nothing executable at $bin"
echo -e "${MUTED} The copy step reported success but left no runnable binary.${NC}"
return 1
fi
local help rc
help="$("$bin" --help 2>&1 </dev/null || true)"
rc=$?
# 137 = SIGKILL, which on macOS is Gatekeeper rejecting an unsigned binary. Name it,
# because "it just quits" sends people to the wrong place entirely.
if [ -z "$help" ]; then
echo -e "${RED}Install failed:${NC} the installed binary produced no output at all."
if [ "$(uname -s)" = "Darwin" ]; then
echo -e "${MUTED} On macOS this is usually Gatekeeper killing an unsigned binary (SIGKILL/137).${NC}"
echo -e "${MUTED} Try: codesign --force --deep --sign - \"$bin\"${NC}"
fi
return 1
fi
# Two independent markers, so renaming one command group cannot condemn a healthy install.
# Here-strings, not `echo | grep -q`: under `set -o pipefail` grep -q exits on its first match,
# echo can then die of SIGPIPE, and the pipeline FAILS on a correct binary. Measured: 1 in 30
# runs on a fresh Ubuntu VM, which aborted a whole install (#192964 R3).
if grep -qi atlas <<<"$help" && grep -qi bloq <<<"$help"; then
return 0
fi
echo -e "${RED}Install failed:${NC} the binary at $bin runs, but it is NOT the IRIS platform CLI."
echo -e "${MUTED} It is missing the platform command surface (no atlas, no bloq).${NC}"
echo -e "${MUTED} This is almost always the desktop app's bundled sidecar written over your CLI.${NC}"
echo -e "${MUTED} Report it against bug #183738 and do not use this binary.${NC}"
return 1
}
install_from_binary() {
print_message info "\n${MUTED}Installing ${NC}IRIS CLI ${MUTED}from: ${NC}$binary_path"
cp "$binary_path" "${INSTALL_DIR}/iris"
chmod 755 "${INSTALL_DIR}/iris"
# Ad-hoc sign on macOS so Gatekeeper doesn't SIGKILL the binary (exit 137)
if [ "$(uname -s)" = "Darwin" ] && command -v codesign >/dev/null 2>&1; then
codesign --force --deep --sign - "${INSTALL_DIR}/iris" 2>/dev/null || true
fi
# --binary is the flag that caused #183738: the desktop app pointed it at its own
# opencode sidecar and overwrote the product on every launch. The app no longer passes
# it, but the flag still exists and anyone can hand it the wrong file — so this path
# needs the read-back MORE than the download path, not less.
verify_installed_cli || exit 1
}
if [ "$only_docs_mode" = "true" ]; then
print_message info "${MUTED}Mode: --only-docs (refreshing IRIS docs, skipping binary install)${NC}"
# Skip binary install. The --only-docs flag also disables every other
# component except 4b (scaffold_iris_docs), so the script flows naturally
# through the rest, runs 4b, and exits at the bottom.
elif [ -n "$binary_path" ]; then
install_from_binary
else
check_version
download_and_install
fi
# ─── PATH setup (env file pattern, like Rust/Bun) ────────────────────────────
# Create ~/.iris/env — a single sourceable file that sets up PATH.
# Then add `source ~/.iris/env` to the user's shell config.
IRIS_ENV_FILE="$HOME/.iris/env"
current_shell=$(basename "$SHELL")
if [ "$current_shell" = "fish" ]; then
cat > "$IRIS_ENV_FILE" << 'ENVF'
# IRIS CLI PATH setup (sourced by your shell config)
if not contains "$HOME/.iris/bin" $PATH
set -gx PATH "$HOME/.iris/bin" $PATH
end
ENVF
else
cat > "$IRIS_ENV_FILE" << 'ENVF'
# IRIS CLI PATH setup (sourced by your shell config)
case ":${PATH}:" in
*:"$HOME/.iris/bin":*) ;;
*) export PATH="$HOME/.iris/bin:$PATH" ;;
esac
ENVF
fi
# Source it now so iris works in the current session
. "$IRIS_ENV_FILE"
# Add source line to shell config (if not already there)
if [[ "$no_modify_path" != "true" ]]; then
XDG_CONFIG_HOME=${XDG_CONFIG_HOME:-$HOME/.config}
# Which files get the source line. EVERY one listed, not the first that exists (#184675).
# The old loop stopped at ~/.zshrc, which only INTERACTIVE zsh reads — so `zsh -c`, login
# shells, launchd, cron and GUI-launched MCP clients never had iris on PATH. ~/.zshenv is
# read by every zsh. For bash: ~/.bashrc (interactive) plus the login file — but never create
# ~/.bash_profile beside an existing ~/.profile, which would stop bash reading ~/.profile.
# Files marked "!" are created if missing; the rest are only written if they already exist.
case $current_shell in
fish) config_files="!$HOME/.config/fish/config.fish" ;;
zsh) config_files="!$HOME/.zshenv $HOME/.zshrc" ;;
bash)
if [[ -f "$HOME/.bash_profile" ]]; then login_file="$HOME/.bash_profile"; else login_file="$HOME/.profile"; fi
config_files="!$HOME/.bashrc !$login_file" ;;
*) config_files="!$HOME/.profile $HOME/.bashrc" ;;
esac
if [ "$current_shell" = "fish" ]; then
source_line="source \"$IRIS_ENV_FILE\""
else
source_line=". \"$HOME/.iris/env\""
fi
for entry in $config_files; do
config_file="${entry#!}"
if [[ ! -f "$config_file" ]]; then
[[ "$entry" == !* ]] || continue
mkdir -p "$(dirname "$config_file")" 2>/dev/null
touch "$config_file" 2>/dev/null || continue
fi
if ! grep -q "\.iris/env" "$config_file" 2>/dev/null; then
echo "" >> "$config_file"
echo "# IRIS CLI" >> "$config_file"
echo "$source_line" >> "$config_file"
fi
done
fi
# Persist a directory on PATH for FUTURE shells by appending to ~/.iris/env — the one
# sourceable file the block above already wired into the user's shell config.
#
# #184930: install_node used to end with `add_to_path "$config_file" ... 2>/dev/null || true`.
# No function of that name has ever existed in this script — grep found exactly one hit in
# 3,011 lines, the call itself — and the redirect swallowed "command not found". So a fresh
# install put Node on PATH for the installer's own session and nowhere else: the daemon then
# died on the next reboot with `node` not found, while `iris-daemon start` still reported
# success. ("$config_file" was also unbound under `set -u` whenever --no-modify-path was
# passed, so the dead call had a second way to fail.)
#
# Appending here rather than editing .zshrc again on purpose: a second writer to shell
# configs is how the first one stops being trustworthy. One mechanism, one file.
persist_path_in_iris_env() {
local dir="$1"
if [ ! -f "$IRIS_ENV_FILE" ]; then
print_message warning "Could not put $dir on PATH: $IRIS_ENV_FILE is missing."
print_message info " Add this to your shell config by hand: export PATH=\"$dir:\$PATH\""
return 1
fi
if grep -qF "$dir" "$IRIS_ENV_FILE" 2>/dev/null; then
return 0
fi
if [ "$current_shell" = "fish" ]; then
{
printf '\n'
printf 'if not contains "%s" $PATH\n' "$dir"
printf ' set -gx PATH "%s" $PATH\n' "$dir"
printf 'end\n'