-
Notifications
You must be signed in to change notification settings - Fork 172
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·1761 lines (1562 loc) · 67.2 KB
/
install.sh
File metadata and controls
executable file
·1761 lines (1562 loc) · 67.2 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
#
# Databricks AI Dev Kit - Unified Installer
#
# Installs skills, MCP server, and configuration for Claude Code, Cursor, OpenAI Codex, GitHub Copilot, and Gemini CLI.
#
# Usage: bash <(curl -sL https://raw.githubusercontent.com/databricks-solutions/ai-dev-kit/main/install.sh) [OPTIONS]
#
# Examples:
# # Basic installation (project scoped, prompts for inputs, uses latest release)
# bash <(curl -sL https://raw.githubusercontent.com/databricks-solutions/ai-dev-kit/main/install.sh)
#
# # Global installation with force reinstall
# bash <(curl -sL https://raw.githubusercontent.com/databricks-solutions/ai-dev-kit/main/install.sh) --global --force
#
# # Specify profile and force reinstall
# bash <(curl -sL https://raw.githubusercontent.com/databricks-solutions/ai-dev-kit/main/install.sh) --profile DEFAULT --force
#
# # Install for specific tools only
# bash <(curl -sL https://raw.githubusercontent.com/databricks-solutions/ai-dev-kit/main/install.sh) --tools cursor,codex,copilot,gemini
#
# # Skills only (skip MCP server)
# bash <(curl -sL https://raw.githubusercontent.com/databricks-solutions/ai-dev-kit/main/install.sh) --skills-only
#
# # Install skills for a specific profile
# bash <(curl -sL https://raw.githubusercontent.com/databricks-solutions/ai-dev-kit/main/install.sh) --skills-profile data-engineer
#
# # Install multiple profiles
# bash <(curl -sL https://raw.githubusercontent.com/databricks-solutions/ai-dev-kit/main/install.sh) --skills-profile data-engineer,ai-ml-engineer
#
# # Install specific skills only
# bash <(curl -sL https://raw.githubusercontent.com/databricks-solutions/ai-dev-kit/main/install.sh) --skills databricks-jobs,databricks-dbsql
#
# # List available skills and profiles
# bash <(curl -sL https://raw.githubusercontent.com/databricks-solutions/ai-dev-kit/main/install.sh) --list-skills
#
# Alternative: Use environment variables
# DEVKIT_TOOLS=cursor curl -sL https://raw.githubusercontent.com/databricks-solutions/ai-dev-kit/main/install.sh | bash
# DEVKIT_FORCE=true DEVKIT_PROFILE=DEFAULT curl -sL https://raw.githubusercontent.com/databricks-solutions/ai-dev-kit/main/install.sh | bash
#
set -e
# Defaults (can be overridden by environment variables or command-line arguments)
PROFILE="${DEVKIT_PROFILE:-DEFAULT}"
SCOPE="${DEVKIT_SCOPE:-project}"
SCOPE_EXPLICIT=false # Track if --global was explicitly passed
FORCE="${DEVKIT_FORCE:-false}"
IS_UPDATE=false
SILENT="${DEVKIT_SILENT:-false}"
TOOLS="${DEVKIT_TOOLS:-}"
USER_TOOLS=""
USER_MCP_PATH="${DEVKIT_MCP_PATH:-}"
SKILLS_PROFILE="${DEVKIT_SKILLS_PROFILE:-}"
USER_SKILLS="${DEVKIT_SKILLS:-}"
# Convert string booleans from env vars to actual booleans
[ "$FORCE" = "true" ] || [ "$FORCE" = "1" ] && FORCE=true || FORCE=false
[ "$SILENT" = "true" ] || [ "$SILENT" = "1" ] && SILENT=true || SILENT=false
# Check if scope was explicitly set via env var
[ -n "${DEVKIT_SCOPE:-}" ] && SCOPE_EXPLICIT=true
OWNER="databricks-solutions"
REPO="ai-dev-kit"
if [ -n "${DEVKIT_BRANCH:-}" ]; then
BRANCH="$DEVKIT_BRANCH"
else
BRANCH="$(
curl -s "https://api.github.com/repos/${OWNER}/${REPO}/releases/latest" \
| grep '"tag_name"' \
| sed -E 's/.*"tag_name": *"([^"]+)".*/\1/'
)"
# Fallback to main if we couldn't fetch the latest release
[ -z "$BRANCH" ] && BRANCH="main"
fi
# Installation mode defaults
INSTALL_MCP=true
INSTALL_SKILLS=true
# Minimum required versions
MIN_CLI_VERSION="0.278.0"
MIN_SDK_VERSION="0.85.0"
# Colors
G='\033[0;32m' Y='\033[1;33m' R='\033[0;31m' BL='\033[0;34m' B='\033[1m' D='\033[2m' N='\033[0m'
# Databricks skills (bundled in repo)
SKILLS="databricks-agent-bricks databricks-aibi-dashboards databricks-app-python databricks-asset-bundles databricks-config databricks-dbsql databricks-docs databricks-genie databricks-iceberg databricks-jobs databricks-lakebase-autoscale databricks-lakebase-provisioned databricks-metric-views databricks-mlflow-evaluation databricks-model-serving databricks-parsing databricks-python-sdk databricks-spark-declarative-pipelines databricks-spark-structured-streaming databricks-synthetic-data-gen databricks-unity-catalog databricks-unstructured-pdf-generation databricks-vector-search databricks-zerobus-ingest spark-python-data-source"
# MLflow skills (fetched from mlflow/skills repo)
MLFLOW_SKILLS="agent-evaluation analyze-mlflow-chat-session analyze-mlflow-trace instrumenting-with-mlflow-tracing mlflow-onboarding querying-mlflow-metrics retrieving-mlflow-traces searching-mlflow-docs"
MLFLOW_RAW_URL="https://raw.githubusercontent.com/mlflow/skills/main"
# APX skills (fetched from databricks-solutions/apx repo)
APX_SKILLS="databricks-app-apx"
APX_RAW_URL="https://raw.githubusercontent.com/databricks-solutions/apx/main/skills/apx"
# ─── Skill profiles ──────────────────────────────────────────
# Core skills always installed regardless of profile selection
CORE_SKILLS="databricks-config databricks-docs databricks-python-sdk databricks-unity-catalog"
# Profile definitions (non-core skills only — core skills are always added)
PROFILE_DATA_ENGINEER="databricks-spark-declarative-pipelines databricks-spark-structured-streaming databricks-jobs databricks-asset-bundles databricks-dbsql databricks-iceberg databricks-zerobus-ingest spark-python-data-source databricks-metric-views databricks-synthetic-data-gen"
PROFILE_ANALYST="databricks-aibi-dashboards databricks-dbsql databricks-genie databricks-metric-views"
PROFILE_AIML_ENGINEER="databricks-agent-bricks databricks-vector-search databricks-model-serving databricks-genie databricks-parsing databricks-unstructured-pdf-generation databricks-mlflow-evaluation databricks-synthetic-data-gen databricks-jobs"
PROFILE_AIML_MLFLOW="agent-evaluation analyze-mlflow-chat-session analyze-mlflow-trace instrumenting-with-mlflow-tracing mlflow-onboarding querying-mlflow-metrics retrieving-mlflow-traces searching-mlflow-docs"
PROFILE_APP_DEVELOPER="databricks-app-python databricks-app-apx databricks-lakebase-autoscale databricks-lakebase-provisioned databricks-model-serving databricks-dbsql databricks-jobs databricks-asset-bundles"
# Selected skills (populated during profile selection)
SELECTED_SKILLS=""
SELECTED_MLFLOW_SKILLS=""
SELECTED_APX_SKILLS=""
# Output helpers
msg() { [ "$SILENT" = true ] || echo -e " $*"; }
ok() { [ "$SILENT" = true ] || echo -e " ${G}✓${N} $*"; }
warn() { [ "$SILENT" = true ] || echo -e " ${Y}!${N} $*"; }
die() { echo -e " ${R}✗${N} $*" >&2; exit 1; } # Always show errors
step() { [ "$SILENT" = true ] || echo -e "\n${B}$*${N}"; }
# Parse arguments
while [ $# -gt 0 ]; do
case $1 in
-p|--profile) PROFILE="$2"; shift 2 ;;
-g|--global) SCOPE="global"; SCOPE_EXPLICIT=true; shift ;;
-b|--branch) BRANCH="$2"; shift 2 ;;
--skills-only) INSTALL_MCP=false; shift ;;
--mcp-only) INSTALL_SKILLS=false; shift ;;
--mcp-path) USER_MCP_PATH="$2"; shift 2 ;;
--skills-profile) SKILLS_PROFILE="$2"; shift 2 ;;
--skills) USER_SKILLS="$2"; shift 2 ;;
--list-skills) LIST_SKILLS=true; shift ;;
--silent) SILENT=true; shift ;;
--tools) USER_TOOLS="$2"; shift 2 ;;
-f|--force) FORCE=true; shift ;;
-h|--help)
echo "Databricks AI Dev Kit Installer"
echo ""
echo "Usage: bash <(curl -sL .../install.sh) [OPTIONS]"
echo ""
echo "Options:"
echo " -p, --profile NAME Databricks profile (default: DEFAULT)"
echo " -b, --branch NAME Git branch/tag to install (default: latest release)"
echo " -g, --global Install globally for all projects"
echo " --skills-only Skip MCP server setup"
echo " --mcp-only Skip skills installation"
echo " --mcp-path PATH Path to MCP server installation (default: ~/.ai-dev-kit)"
echo " --silent Silent mode (no output except errors)"
echo " --tools LIST Comma-separated: claude,cursor,copilot,codex,gemini"
echo " --skills-profile LIST Comma-separated profiles: all,data-engineer,analyst,ai-ml-engineer,app-developer"
echo " --skills LIST Comma-separated skill names to install (overrides profile)"
echo " --list-skills List available skills and profiles, then exit"
echo " -f, --force Force reinstall"
echo " -h, --help Show this help"
echo ""
echo "Environment Variables (alternative to flags):"
echo " DEVKIT_PROFILE Databricks config profile"
echo " DEVKIT_BRANCH Git branch/tag to install (default: latest release)"
echo " DEVKIT_SCOPE 'project' or 'global'"
echo " DEVKIT_TOOLS Comma-separated list of tools"
echo " DEVKIT_FORCE Set to 'true' to force reinstall"
echo " DEVKIT_MCP_PATH Path to MCP server installation"
echo " DEVKIT_SKILLS_PROFILE Comma-separated skill profiles"
echo " DEVKIT_SKILLS Comma-separated skill names"
echo " DEVKIT_SILENT Set to 'true' for silent mode"
echo " AIDEVKIT_HOME Installation directory (default: ~/.ai-dev-kit)"
echo ""
echo "Examples:"
echo " # Using environment variables"
echo " DEVKIT_TOOLS=cursor curl -sL .../install.sh | bash"
echo ""
exit 0 ;;
*) die "Unknown option: $1 (use -h for help)" ;;
esac
done
# ─── --list-skills handler ─────────────────────────────────────
if [ "${LIST_SKILLS:-false}" = true ]; then
echo ""
echo -e "${B}Available Skill Profiles${N}"
echo "────────────────────────────────"
echo ""
echo -e " ${B}all${N} All 34 skills (default)"
echo -e " ${B}data-engineer${N} Pipelines, Spark, Jobs, Streaming (14 skills)"
echo -e " ${B}analyst${N} Dashboards, SQL, Genie, Metrics (8 skills)"
echo -e " ${B}ai-ml-engineer${N} Agents, RAG, Vector Search, MLflow (17 skills)"
echo -e " ${B}app-developer${N} Apps, Lakebase, Deployment (10 skills)"
echo ""
echo -e "${B}Core Skills${N} (always installed)"
echo "────────────────────────────────"
for skill in $CORE_SKILLS; do
echo -e " ${G}✓${N} $skill"
done
echo ""
echo -e "${B}Data Engineer${N}"
echo "────────────────────────────────"
for skill in $PROFILE_DATA_ENGINEER; do
echo -e " $skill"
done
echo ""
echo -e "${B}Business Analyst${N}"
echo "────────────────────────────────"
for skill in $PROFILE_ANALYST; do
echo -e " $skill"
done
echo ""
echo -e "${B}AI/ML Engineer${N}"
echo "────────────────────────────────"
for skill in $PROFILE_AIML_ENGINEER; do
echo -e " $skill"
done
echo -e " ${D}+ MLflow skills:${N}"
for skill in $PROFILE_AIML_MLFLOW; do
echo -e " $skill"
done
echo ""
echo -e "${B}App Developer${N}"
echo "────────────────────────────────"
for skill in $PROFILE_APP_DEVELOPER; do
echo -e " $skill"
done
echo ""
echo -e "${B}MLflow Skills${N} (from mlflow/skills repo)"
echo "────────────────────────────────"
for skill in $MLFLOW_SKILLS; do
echo -e " $skill"
done
echo ""
echo -e "${B}APX Skills${N} (from databricks-solutions/apx repo)"
echo "────────────────────────────────"
for skill in $APX_SKILLS; do
echo -e " $skill"
done
echo ""
echo -e "${D}Usage: bash install.sh --skills-profile data-engineer,ai-ml-engineer${N}"
echo -e "${D} bash install.sh --skills databricks-jobs,databricks-dbsql${N}"
echo ""
exit 0
fi
# Set configuration URLs after parsing branch argument
REPO_URL="https://github.com/databricks-solutions/ai-dev-kit.git"
RAW_URL="https://raw.githubusercontent.com/databricks-solutions/ai-dev-kit/${BRANCH}"
INSTALL_DIR="${AIDEVKIT_HOME:-$HOME/.ai-dev-kit}"
REPO_DIR="$INSTALL_DIR/repo"
VENV_DIR="$INSTALL_DIR/.venv"
VENV_PYTHON="$VENV_DIR/bin/python"
MCP_ENTRY="$REPO_DIR/databricks-mcp-server/run_server.py"
# ─── Interactive helpers ────────────────────────────────────────
# Reads from /dev/tty so prompts work even when piped via curl | bash
# Simple text prompt with default value
prompt() {
local prompt_text=$1
local default_value=$2
local result=""
if [ "$SILENT" = true ]; then
echo "$default_value"
return
fi
if [ -e /dev/tty ]; then
printf " %b [%s]: " "$prompt_text" "$default_value" > /dev/tty
read -r result < /dev/tty
elif [ -t 0 ]; then
printf " %b [%s]: " "$prompt_text" "$default_value"
read -r result
else
echo "$default_value"
return
fi
if [ -z "$result" ]; then
echo "$default_value"
else
echo "$result"
fi
}
# Interactive checkbox selector using arrow keys + space/enter + "Done" button
# Outputs space-separated selected values to stdout
# Args: "Label|value|on_or_off|hint" ...
checkbox_select() {
# Parse items
local -a labels=()
local -a values=()
local -a states=()
local -a hints=()
local count=0
for item in "$@"; do
IFS='|' read -r label value state hint <<< "$item"
labels+=("$label")
values+=("$value")
hints+=("$hint")
if [ "$state" = "on" ]; then
states+=(1)
else
states+=(0)
fi
count=$((count + 1))
done
local cursor=0
local total_rows=$((count + 2)) # items + blank line + Done button
# Draw the checkbox list + Done button
_checkbox_draw() {
local i
for i in $(seq 0 $((count - 1))); do
local check=" "
[ "${states[$i]}" = "1" ] && check="\033[0;32m✓\033[0m"
local arrow=" "
[ "$i" = "$cursor" ] && arrow="\033[0;34m❯\033[0m "
local hint_style="\033[2m"
[ "${states[$i]}" = "1" ] && hint_style="\033[0;32m"
printf "\033[2K %b[%b] %-16s %b%s\033[0m\n" "$arrow" "$check" "${labels[$i]}" "$hint_style" "${hints[$i]}" > /dev/tty
done
# Blank separator line
printf "\033[2K\n" > /dev/tty
# Done button
if [ "$cursor" = "$count" ]; then
printf "\033[2K \033[0;34m❯\033[0m \033[1;32m[ Confirm ]\033[0m\n" > /dev/tty
else
printf "\033[2K \033[2m[ Confirm ]\033[0m\n" > /dev/tty
fi
}
# Print instructions
printf "\n \033[2m↑/↓ navigate · space/enter select · enter on Confirm to finish\033[0m\n\n" > /dev/tty
# Hide cursor
printf "\033[?25l" > /dev/tty
# Restore cursor on exit (Ctrl+C safety)
trap 'printf "\033[?25h" > /dev/tty 2>/dev/null' EXIT
# Initial draw
_checkbox_draw
# Input loop
while true; do
# Move back to top of drawn area and redraw
printf "\033[%dA" "$total_rows" > /dev/tty
_checkbox_draw
# Read input
local key=""
IFS= read -rsn1 key < /dev/tty 2>/dev/null
if [ "$key" = $'\x1b' ]; then
local s1="" s2=""
read -rsn1 s1 < /dev/tty 2>/dev/null
read -rsn1 s2 < /dev/tty 2>/dev/null
if [ "$s1" = "[" ]; then
case "$s2" in
A) [ "$cursor" -gt 0 ] && cursor=$((cursor - 1)) ;; # Up
B) [ "$cursor" -lt "$count" ] && cursor=$((cursor + 1)) ;; # Down (can go to Done)
esac
fi
elif [ "$key" = " " ] || [ "$key" = "" ]; then
# Space or Enter
if [ "$cursor" -lt "$count" ]; then
# On a checkbox item — toggle it
if [ "${states[$cursor]}" = "1" ]; then
states[$cursor]=0
else
states[$cursor]=1
fi
else
# On the Confirm button — done
printf "\033[%dA" "$total_rows" > /dev/tty
_checkbox_draw
break
fi
fi
done
# Show cursor again
printf "\033[?25h" > /dev/tty
trap - EXIT
# Build result
local selected=""
for i in $(seq 0 $((count - 1))); do
if [ "${states[$i]}" = "1" ]; then
selected="${selected:+$selected }${values[$i]}"
fi
done
echo "$selected"
}
# Interactive single-select using arrow keys + enter + "Confirm" button
# Outputs the selected value to stdout
# Args: "Label|value|selected|hint" ... (exactly one should have selected=on)
radio_select() {
# Parse items
local -a labels=()
local -a values=()
local -a hints=()
local count=0
local selected=0
for item in "$@"; do
IFS='|' read -r label value state hint <<< "$item"
labels+=("$label")
values+=("$value")
hints+=("$hint")
[ "$state" = "on" ] && selected=$count
count=$((count + 1))
done
local cursor=0
local total_rows=$((count + 2)) # items + blank line + Confirm button
_radio_draw() {
local i
for i in $(seq 0 $((count - 1))); do
local dot="○"
local dot_color="\033[2m"
[ "$i" = "$selected" ] && dot="●" && dot_color="\033[0;32m"
local arrow=" "
[ "$i" = "$cursor" ] && arrow="\033[0;34m❯\033[0m "
local hint_style="\033[2m"
[ "$i" = "$selected" ] && hint_style="\033[0;32m"
printf "\033[2K %b%b%b %-20s %b%s\033[0m\n" "$arrow" "$dot_color" "$dot" "${labels[$i]}" "$hint_style" "${hints[$i]}" > /dev/tty
done
printf "\033[2K\n" > /dev/tty
if [ "$cursor" = "$count" ]; then
printf "\033[2K \033[0;34m❯\033[0m \033[1;32m[ Confirm ]\033[0m\n" > /dev/tty
else
printf "\033[2K \033[2m[ Confirm ]\033[0m\n" > /dev/tty
fi
}
printf "\n \033[2m↑/↓ navigate · enter confirm · space preview\033[0m\n\n" > /dev/tty
printf "\033[?25l" > /dev/tty
trap 'printf "\033[?25h" > /dev/tty 2>/dev/null' EXIT
_radio_draw
while true; do
printf "\033[%dA" "$total_rows" > /dev/tty
_radio_draw
local key=""
IFS= read -rsn1 key < /dev/tty 2>/dev/null
if [ "$key" = $'\x1b' ]; then
local s1="" s2=""
read -rsn1 s1 < /dev/tty 2>/dev/null
read -rsn1 s2 < /dev/tty 2>/dev/null
if [ "$s1" = "[" ]; then
case "$s2" in
A) [ "$cursor" -gt 0 ] && cursor=$((cursor - 1)) ;;
B) [ "$cursor" -lt "$count" ] && cursor=$((cursor + 1)) ;;
esac
fi
elif [ "$key" = "" ]; then
# Enter — select current item and confirm immediately
if [ "$cursor" -lt "$count" ]; then
selected=$cursor
fi
printf "\033[%dA" "$total_rows" > /dev/tty
_radio_draw
break
elif [ "$key" = " " ]; then
# Space — select but keep browsing
if [ "$cursor" -lt "$count" ]; then
selected=$cursor
fi
fi
done
printf "\033[?25h" > /dev/tty
trap - EXIT
echo "${values[$selected]}"
}
# ─── Tool detection & selection ─────────────────────────────────
detect_tools() {
# If provided via --tools flag or TOOLS env var, skip detection and prompts
if [ -n "$USER_TOOLS" ]; then
TOOLS=$(echo "$USER_TOOLS" | tr ',' ' ')
return
elif [ -n "$TOOLS" ]; then
# TOOLS env var already set, just normalize it
TOOLS=$(echo "$TOOLS" | tr ',' ' ')
return
fi
# Auto-detect what's installed
local has_claude=false
local has_cursor=false
local has_codex=false
local has_copilot=false
local has_gemini=false
command -v claude >/dev/null 2>&1 && has_claude=true
{ [ -d "/Applications/Cursor.app" ] || command -v cursor >/dev/null 2>&1; } && has_cursor=true
command -v codex >/dev/null 2>&1 && has_codex=true
{ [ -d "/Applications/Visual Studio Code.app" ] || command -v code >/dev/null 2>&1; } && has_copilot=true
{ command -v gemini >/dev/null 2>&1 || [ -f "$HOME/.gemini/local/gemini" ]; } && has_gemini=true
# Build checkbox items: "Label|value|on_or_off|hint"
local claude_state="off" cursor_state="off" codex_state="off" copilot_state="off" gemini_state="off"
local claude_hint="not found" cursor_hint="not found" codex_hint="not found" copilot_hint="not found" gemini_hint="not found"
[ "$has_claude" = true ] && claude_state="on" && claude_hint="detected"
[ "$has_cursor" = true ] && cursor_state="on" && cursor_hint="detected"
[ "$has_codex" = true ] && codex_state="on" && codex_hint="detected"
[ "$has_copilot" = true ] && copilot_state="on" && copilot_hint="detected"
[ "$has_gemini" = true ] && gemini_state="on" && gemini_hint="detected"
# If nothing detected, pre-select claude as default
if [ "$has_claude" = false ] && [ "$has_cursor" = false ] && [ "$has_codex" = false ] && [ "$has_copilot" = false ] && [ "$has_gemini" = false ]; then
claude_state="on"
claude_hint="default"
fi
# Interactive or fallback
if [ "$SILENT" = false ] && [ -e /dev/tty ]; then
[ "$SILENT" = false ] && echo ""
[ "$SILENT" = false ] && echo -e " ${B}Select tools to install for:${N}"
TOOLS=$(checkbox_select \
"Claude Code|claude|${claude_state}|${claude_hint}" \
"Cursor|cursor|${cursor_state}|${cursor_hint}" \
"GitHub Copilot|copilot|${copilot_state}|${copilot_hint}" \
"OpenAI Codex|codex|${codex_state}|${codex_hint}" \
"Gemini CLI|gemini|${gemini_state}|${gemini_hint}" \
)
else
# Silent: use detected defaults
local tools=""
[ "$has_claude" = true ] && tools="claude"
[ "$has_cursor" = true ] && tools="${tools:+$tools }cursor"
[ "$has_copilot" = true ] && tools="${tools:+$tools }copilot"
[ "$has_codex" = true ] && tools="${tools:+$tools }codex"
[ "$has_gemini" = true ] && tools="${tools:+$tools }gemini"
[ -z "$tools" ] && tools="claude"
TOOLS="$tools"
fi
# Validate we have at least one
if [ -z "$TOOLS" ]; then
warn "No tools selected, defaulting to Claude Code"
TOOLS="claude"
fi
}
# ─── Databricks profile selection ─────────────────────────────
prompt_profile() {
# If provided via --profile flag (non-default), skip prompt
if [ "$PROFILE" != "DEFAULT" ]; then
return
fi
# Skip in silent mode or non-interactive
if [ "$SILENT" = true ] || [ ! -e /dev/tty ]; then
return
fi
# Detect existing profiles from ~/.databrickscfg
local cfg_file="$HOME/.databrickscfg"
local -a profiles=()
if [ -f "$cfg_file" ]; then
while IFS= read -r line; do
# Match [PROFILE_NAME] sections
if [[ "$line" =~ ^\[([a-zA-Z0-9_-]+)\]$ ]]; then
profiles+=("${BASH_REMATCH[1]}")
fi
done < "$cfg_file"
fi
echo ""
echo -e " ${B}Select Databricks profile${N}"
if [ ${#profiles[@]} -gt 0 ] && [ -e /dev/tty ]; then
# Build radio items: "Label|value|on_or_off|hint"
local -a items=()
for p in "${profiles[@]}"; do
local state="off"
local hint=""
[ "$p" = "DEFAULT" ] && state="on" && hint="default"
items+=("${p}|${p}|${state}|${hint}")
done
# Add custom profile option at the end
items+=("Custom profile name...|__CUSTOM__|off|Enter a custom profile name")
# If no DEFAULT profile exists, pre-select the first one
local has_default=false
for p in "${profiles[@]}"; do
[ "$p" = "DEFAULT" ] && has_default=true
done
if [ "$has_default" = false ]; then
items[0]=$(echo "${items[0]}" | sed 's/|off|/|on|/')
fi
local selected_profile
selected_profile=$(radio_select "${items[@]}")
# If custom was selected, prompt for name
if [ "$selected_profile" = "__CUSTOM__" ]; then
echo ""
local custom_name
custom_name=$(prompt "Enter profile name" "DEFAULT")
PROFILE="$custom_name"
else
PROFILE="$selected_profile"
fi
else
echo -e " ${D}No ~/.databrickscfg found. You can authenticate after install.${N}"
echo ""
local selected
selected=$(prompt "Profile name" "DEFAULT")
PROFILE="$selected"
fi
}
# ─── MCP path selection ────────────────────────────────────────
prompt_mcp_path() {
# If provided via --mcp-path flag, skip prompt
if [ -n "$USER_MCP_PATH" ]; then
INSTALL_DIR="$USER_MCP_PATH"
elif [ "$SILENT" = false ] && [ -e /dev/tty ]; then
[ "$SILENT" = false ] && echo ""
[ "$SILENT" = false ] && echo -e " ${B}MCP server location${N}"
[ "$SILENT" = false ] && echo -e " ${D}The MCP server runtime (Python venv + source) will be installed here.${N}"
[ "$SILENT" = false ] && echo -e " ${D}Shared across all your projects — only the config files are per-project.${N}"
[ "$SILENT" = false ] && echo ""
local selected
selected=$(prompt "Install path" "$INSTALL_DIR")
# Expand ~ to $HOME
INSTALL_DIR="${selected/#\~/$HOME}"
fi
# Update derived paths
REPO_DIR="$INSTALL_DIR/repo"
VENV_DIR="$INSTALL_DIR/.venv"
VENV_PYTHON="$VENV_DIR/bin/python"
MCP_ENTRY="$REPO_DIR/databricks-mcp-server/run_server.py"
}
# ─── Skill profile selection ──────────────────────────────────
# Resolve selected skills from profile names or explicit skill list
resolve_skills() {
local db_skills="" mlflow_skills="" apx_skills=""
# Priority 1: Explicit --skills flag (comma-separated skill names)
if [ -n "$USER_SKILLS" ]; then
local user_list
user_list=$(echo "$USER_SKILLS" | tr ',' ' ')
# Separate into DB, MLflow, and APX buckets, always include core
db_skills="$CORE_SKILLS"
for skill in $user_list; do
if echo "$MLFLOW_SKILLS" | grep -qw "$skill"; then
mlflow_skills="${mlflow_skills:+$mlflow_skills }$skill"
elif echo "$APX_SKILLS" | grep -qw "$skill"; then
apx_skills="${apx_skills:+$apx_skills }$skill"
else
db_skills="${db_skills:+$db_skills }$skill"
fi
done
# Deduplicate
SELECTED_SKILLS=$(echo "$db_skills" | tr ' ' '\n' | sort -u | tr '\n' ' ')
SELECTED_MLFLOW_SKILLS=$(echo "$mlflow_skills" | tr ' ' '\n' | sort -u | tr '\n' ' ')
SELECTED_APX_SKILLS=$(echo "$apx_skills" | tr ' ' '\n' | sort -u | tr '\n' ' ')
return
fi
# Priority 2: --skills-profile flag or interactive selection
if [ -z "$SKILLS_PROFILE" ] || [ "$SKILLS_PROFILE" = "all" ]; then
SELECTED_SKILLS="$SKILLS"
SELECTED_MLFLOW_SKILLS="$MLFLOW_SKILLS"
SELECTED_APX_SKILLS="$APX_SKILLS"
return
fi
# Build union of selected profiles (comma-separated)
db_skills="$CORE_SKILLS"
mlflow_skills=""
apx_skills=""
local profiles
profiles=$(echo "$SKILLS_PROFILE" | tr ',' ' ')
for profile in $profiles; do
case $profile in
all)
SELECTED_SKILLS="$SKILLS"
SELECTED_MLFLOW_SKILLS="$MLFLOW_SKILLS"
SELECTED_APX_SKILLS="$APX_SKILLS"
return
;;
data-engineer)
db_skills="$db_skills $PROFILE_DATA_ENGINEER"
;;
analyst)
db_skills="$db_skills $PROFILE_ANALYST"
;;
ai-ml-engineer)
db_skills="$db_skills $PROFILE_AIML_ENGINEER"
mlflow_skills="$mlflow_skills $PROFILE_AIML_MLFLOW"
;;
app-developer)
db_skills="$db_skills $PROFILE_APP_DEVELOPER"
apx_skills="$apx_skills $APX_SKILLS"
;;
*)
warn "Unknown skill profile: $profile (ignored)"
;;
esac
done
# Deduplicate
SELECTED_SKILLS=$(echo "$db_skills" | tr ' ' '\n' | sort -u | tr '\n' ' ')
SELECTED_MLFLOW_SKILLS=$(echo "$mlflow_skills" | tr ' ' '\n' | sort -u | tr '\n' ' ')
SELECTED_APX_SKILLS=$(echo "$apx_skills" | tr ' ' '\n' | sort -u | tr '\n' ' ')
}
# Interactive skill profile selection (multi-select)
prompt_skills_profile() {
# If provided via --skills or --skills-profile, skip interactive prompt
if [ -n "$USER_SKILLS" ] || [ -n "$SKILLS_PROFILE" ]; then
return
fi
# Skip in silent mode or non-interactive
if [ "$SILENT" = true ] || [ ! -e /dev/tty ]; then
SKILLS_PROFILE="all"
return
fi
# Check for previous selection (scope-local first, then global fallback for upgrades)
local profile_file="$STATE_DIR/.skills-profile"
[ ! -f "$profile_file" ] && [ "$SCOPE" = "project" ] && profile_file="$INSTALL_DIR/.skills-profile"
if [ -f "$profile_file" ]; then
local prev_profile
prev_profile=$(cat "$profile_file")
if [ "$FORCE" != true ]; then
echo ""
local display_profile
display_profile=$(echo "$prev_profile" | tr ',' ', ')
local keep
keep=$(prompt "Previous skill profile: ${B}${display_profile}${N}. Keep? ${D}(Y/n)${N}" "y")
if [ "$keep" = "y" ] || [ "$keep" = "Y" ] || [ "$keep" = "yes" ] || [ -z "$keep" ]; then
SKILLS_PROFILE="$prev_profile"
return
fi
fi
fi
echo ""
echo -e " ${B}Select skill profile(s)${N}"
# Custom checkbox with mutual exclusion: "All" deselects others, others deselect "All"
local -a p_labels=("All Skills" "Data Engineer" "Business Analyst" "AI/ML Engineer" "App Developer" "Custom")
local -a p_values=("all" "data-engineer" "analyst" "ai-ml-engineer" "app-developer" "custom")
local -a p_hints=("Install everything (34 skills)" "Pipelines, Spark, Jobs, Streaming (14 skills)" "Dashboards, SQL, Genie, Metrics (8 skills)" "Agents, RAG, Vector Search, MLflow (17 skills)" "Apps, Lakebase, Deployment (10 skills)" "Pick individual skills")
local -a p_states=(1 0 0 0 0 0) # "All" selected by default
local p_count=6
local p_cursor=0
local p_total_rows=$((p_count + 2))
_profile_draw() {
local i
for i in $(seq 0 $((p_count - 1))); do
local check=" "
[ "${p_states[$i]}" = "1" ] && check="\033[0;32m✓\033[0m"
local arrow=" "
[ "$i" = "$p_cursor" ] && arrow="\033[0;34m❯\033[0m "
local hint_style="\033[2m"
[ "${p_states[$i]}" = "1" ] && hint_style="\033[0;32m"
printf "\033[2K %b[%b] %-20s %b%s\033[0m\n" "$arrow" "$check" "${p_labels[$i]}" "$hint_style" "${p_hints[$i]}" > /dev/tty
done
printf "\033[2K\n" > /dev/tty
if [ "$p_cursor" = "$p_count" ]; then
printf "\033[2K \033[0;34m❯\033[0m \033[1;32m[ Confirm ]\033[0m\n" > /dev/tty
else
printf "\033[2K \033[2m[ Confirm ]\033[0m\n" > /dev/tty
fi
}
printf "\n \033[2m↑/↓ navigate · space/enter select · enter on Confirm to finish\033[0m\n\n" > /dev/tty
printf "\033[?25l" > /dev/tty
trap 'printf "\033[?25h" > /dev/tty 2>/dev/null' EXIT
_profile_draw
while true; do
printf "\033[%dA" "$p_total_rows" > /dev/tty
_profile_draw
local key=""
IFS= read -rsn1 key < /dev/tty 2>/dev/null
if [ "$key" = $'\x1b' ]; then
local s1="" s2=""
read -rsn1 s1 < /dev/tty 2>/dev/null
read -rsn1 s2 < /dev/tty 2>/dev/null
if [ "$s1" = "[" ]; then
case "$s2" in
A) [ "$p_cursor" -gt 0 ] && p_cursor=$((p_cursor - 1)) ;;
B) [ "$p_cursor" -lt "$p_count" ] && p_cursor=$((p_cursor + 1)) ;;
esac
fi
elif [ "$key" = " " ] || [ "$key" = "" ]; then
if [ "$p_cursor" -lt "$p_count" ]; then
# Toggle the current item
if [ "${p_states[$p_cursor]}" = "1" ]; then
p_states[$p_cursor]=0
else
p_states[$p_cursor]=1
# Mutual exclusion: "All" (index 0) vs individual profiles (1-5)
if [ "$p_cursor" = "0" ]; then
# Selected "All" → deselect all others
for j in $(seq 1 $((p_count - 1))); do p_states[$j]=0; done
else
# Selected an individual profile → deselect "All"
p_states[0]=0
fi
fi
else
# On Confirm — done
printf "\033[%dA" "$p_total_rows" > /dev/tty
_profile_draw
break
fi
fi
done
printf "\033[?25h" > /dev/tty
trap - EXIT
# Build result
local selected=""
for i in $(seq 0 $((p_count - 1))); do
if [ "${p_states[$i]}" = "1" ]; then
selected="${selected:+$selected }${p_values[$i]}"
fi
done
# Handle empty selection — default to all
if [ -z "$selected" ]; then
SKILLS_PROFILE="all"
return
fi
# Check if "all" is selected
if echo "$selected" | grep -qw "all"; then
SKILLS_PROFILE="all"
return
fi
# Check if "custom" is selected — show individual skill picker
if echo "$selected" | grep -qw "custom"; then
prompt_custom_skills "$selected"
return
fi
# Store comma-separated profile names
SKILLS_PROFILE=$(echo "$selected" | tr ' ' ',')
}
# Custom individual skill picker
prompt_custom_skills() {
local preselected_profiles="$1"
# Build pre-selection set from any profiles that were also checked
local preselected=""
for profile in $preselected_profiles; do
case $profile in
data-engineer) preselected="$preselected $PROFILE_DATA_ENGINEER" ;;
analyst) preselected="$preselected $PROFILE_ANALYST" ;;
ai-ml-engineer) preselected="$preselected $PROFILE_AIML_ENGINEER $PROFILE_AIML_MLFLOW" ;;
app-developer) preselected="$preselected $PROFILE_APP_DEVELOPER $APX_SKILLS" ;;
esac
done
_is_preselected() {
echo "$preselected" | grep -qw "$1" && echo "on" || echo "off"
}
echo ""
echo -e " ${B}Select individual skills${N}"
echo -e " ${D}Core skills (config, docs, python-sdk, unity-catalog) are always installed${N}"
local selected
selected=$(checkbox_select \
"Spark Pipelines|databricks-spark-declarative-pipelines|$(_is_preselected databricks-spark-declarative-pipelines)|SDP/LDP, CDC, SCD Type 2" \
"Structured Streaming|databricks-spark-structured-streaming|$(_is_preselected databricks-spark-structured-streaming)|Real-time streaming" \
"Jobs & Workflows|databricks-jobs|$(_is_preselected databricks-jobs)|Multi-task orchestration" \
"Asset Bundles|databricks-asset-bundles|$(_is_preselected databricks-asset-bundles)|DABs deployment" \
"Databricks SQL|databricks-dbsql|$(_is_preselected databricks-dbsql)|SQL warehouse queries" \
"Iceberg|databricks-iceberg|$(_is_preselected databricks-iceberg)|Apache Iceberg tables" \
"Zerobus Ingest|databricks-zerobus-ingest|$(_is_preselected databricks-zerobus-ingest)|Streaming ingestion" \
"Python Data Source|spark-python-data-source|$(_is_preselected spark-python-data-source)|Custom Spark data sources" \
"Metric Views|databricks-metric-views|$(_is_preselected databricks-metric-views)|Metric definitions" \
"AI/BI Dashboards|databricks-aibi-dashboards|$(_is_preselected databricks-aibi-dashboards)|Dashboard creation" \
"Genie|databricks-genie|$(_is_preselected databricks-genie)|Natural language SQL" \
"Agent Bricks|databricks-agent-bricks|$(_is_preselected databricks-agent-bricks)|Build AI agents" \
"Vector Search|databricks-vector-search|$(_is_preselected databricks-vector-search)|Similarity search" \
"Model Serving|databricks-model-serving|$(_is_preselected databricks-model-serving)|Deploy models/agents" \
"MLflow Evaluation|databricks-mlflow-evaluation|$(_is_preselected databricks-mlflow-evaluation)|Model evaluation" \
"Parsing|databricks-parsing|$(_is_preselected databricks-parsing)|Document parsing for RAG" \
"Unstructured PDF|databricks-unstructured-pdf-generation|$(_is_preselected databricks-unstructured-pdf-generation)|Synthetic PDFs for RAG" \
"Synthetic Data|databricks-synthetic-data-gen|$(_is_preselected databricks-synthetic-data-gen)|Generate test data" \
"Lakebase Autoscale|databricks-lakebase-autoscale|$(_is_preselected databricks-lakebase-autoscale)|Managed PostgreSQL" \
"Lakebase Provisioned|databricks-lakebase-provisioned|$(_is_preselected databricks-lakebase-provisioned)|Provisioned PostgreSQL" \
"App Python|databricks-app-python|$(_is_preselected databricks-app-python)|Dash, Streamlit, Flask" \
"App APX|databricks-app-apx|$(_is_preselected databricks-app-apx)|FastAPI + React" \
"MLflow Onboarding|mlflow-onboarding|$(_is_preselected mlflow-onboarding)|Getting started" \
"Agent Evaluation|agent-evaluation|$(_is_preselected agent-evaluation)|Evaluate AI agents" \
"MLflow Tracing|instrumenting-with-mlflow-tracing|$(_is_preselected instrumenting-with-mlflow-tracing)|Instrument with tracing" \
"Analyze Traces|analyze-mlflow-trace|$(_is_preselected analyze-mlflow-trace)|Analyze trace data" \
"Retrieve Traces|retrieving-mlflow-traces|$(_is_preselected retrieving-mlflow-traces)|Search & retrieve traces" \
"Analyze Chat Session|analyze-mlflow-chat-session|$(_is_preselected analyze-mlflow-chat-session)|Chat session analysis" \
"Query Metrics|querying-mlflow-metrics|$(_is_preselected querying-mlflow-metrics)|MLflow metrics queries" \
"Search MLflow Docs|searching-mlflow-docs|$(_is_preselected searching-mlflow-docs)|MLflow documentation" \
)
# Use explicit skills list — set USER_SKILLS so resolve_skills handles it
USER_SKILLS=$(echo "$selected" | tr ' ' ',')
}
# Compare semantic versions (returns 0 if $1 >= $2)
version_gte() {
printf '%s\n%s' "$2" "$1" | sort -V -C
}
# Check Databricks CLI version meets minimum requirement
check_cli_version() {
local cli_version
cli_version=$(databricks --version 2>/dev/null | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | head -1)
if [ -z "$cli_version" ]; then
warn "Could not determine Databricks CLI version"
return
fi
if version_gte "$cli_version" "$MIN_CLI_VERSION"; then
ok "Databricks CLI v${cli_version}"
else
warn "Databricks CLI v${cli_version} is outdated (minimum: v${MIN_CLI_VERSION})"
msg " ${B}Upgrade:${N} curl -fsSL https://raw.githubusercontent.com/databricks/setup-cli/main/install.sh | sh"
fi
}
# Check Databricks SDK version in the MCP venv
check_sdk_version() {
local sdk_version
sdk_version=$("$VENV_PYTHON" -c "from databricks.sdk.version import __version__; print(__version__)" 2>/dev/null)
if [ -z "$sdk_version" ]; then
warn "Could not determine Databricks SDK version"
return
fi
if version_gte "$sdk_version" "$MIN_SDK_VERSION"; then
ok "Databricks SDK v${sdk_version}"
else
warn "Databricks SDK v${sdk_version} is outdated (minimum: v${MIN_SDK_VERSION})"
msg " ${B}Upgrade:${N} $VENV_PYTHON -m pip install --upgrade databricks-sdk"
fi
}
# Check prerequisites
check_deps() {
command -v git >/dev/null 2>&1 || die "git required"
ok "git"
if command -v databricks >/dev/null 2>&1; then
check_cli_version
else
warn "Databricks CLI not found. Install: ${B}curl -fsSL https://raw.githubusercontent.com/databricks/setup-cli/main/install.sh | sh${N}"
msg "${D}You can still install, but authentication will require the CLI later.${N}"
fi
if [ "$INSTALL_MCP" = true ]; then
if command -v uv >/dev/null 2>&1; then
PKG="uv"
elif command -v pip3 >/dev/null 2>&1; then
PKG="pip3"
elif command -v pip >/dev/null 2>&1; then
PKG="pip"
else
die "Python package manager required. Install uv: curl -LsSf https://astral.sh/uv/install.sh | sh"
fi
ok "$PKG"
fi