-
Notifications
You must be signed in to change notification settings - Fork 214
Expand file tree
/
Copy pathinstall.ps1
More file actions
1935 lines (1730 loc) · 82.2 KB
/
install.ps1
File metadata and controls
1935 lines (1730 loc) · 82.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
#
# Databricks AI Dev Kit - Unified Installer (Windows)
#
# Installs skills, MCP server, and configuration for Claude Code, Cursor, OpenAI Codex, GitHub Copilot, Gemini CLI, and Antigravity.
#
# Usage: irm https://raw.githubusercontent.com/databricks-solutions/ai-dev-kit/main/install.ps1 -OutFile install.ps1
# .\install.ps1 [OPTIONS]
#
# Examples:
# # Basic installation (uses DEFAULT profile, project scope, latest release)
# irm https://raw.githubusercontent.com/databricks-solutions/ai-dev-kit/main/install.ps1 | iex
#
# # Download and run with options
# irm https://raw.githubusercontent.com/databricks-solutions/ai-dev-kit/main/install.ps1 -OutFile install.ps1
#
# # Global installation with force reinstall
# .\install.ps1 -Global -Force
#
# # Specify profile and force reinstall
# .\install.ps1 -Profile DEFAULT -Force
#
# # Install for specific tools only
# .\install.ps1 -Tools cursor
#
# # Skills only (skip MCP server)
# .\install.ps1 -SkillsOnly
#
# # Install specific branch or tag
# $env:AIDEVKIT_BRANCH = '0.1.0'; .\install.ps1
#
$ErrorActionPreference = "Stop"
# ─── Configuration ────────────────────────────────────────────
$Owner = "databricks-solutions"
$Repo = "ai-dev-kit"
# Determine branch/tag to use
if ($env:AIDEVKIT_BRANCH) {
$Branch = $env:AIDEVKIT_BRANCH
} else {
try {
$latestReleaseUri = "https://api.github.com/repos/$Owner/$Repo/releases/latest"
$latestRelease = Invoke-WebRequest -Uri $latestReleaseUri -Headers @{ "Accept" = "application/json" } -UseBasicParsing -ErrorAction Stop
$Branch = ($latestRelease.Content | ConvertFrom-Json).tag_name
} catch {
$Branch = "main"
}
}
$RepoUrl = "https://github.com/$Owner/$Repo.git"
$RawUrl = "https://raw.githubusercontent.com/$Owner/$Repo/$Branch"
$InstallDir = if ($env:AIDEVKIT_HOME) { $env:AIDEVKIT_HOME } else { Join-Path $env:USERPROFILE ".ai-dev-kit" }
$RepoDir = Join-Path $InstallDir "repo"
$VenvDir = Join-Path $InstallDir ".venv"
$VenvPython = Join-Path $VenvDir "Scripts\python.exe"
$McpEntry = Join-Path $RepoDir "databricks-mcp-server\run_server.py"
# Minimum required versions
$MinCliVersion = "0.278.0"
$MinSdkVersion = "0.85.0"
# ─── Defaults ─────────────────────────────────────────────────
$script:Profile_ = "DEFAULT"
$script:Scope = "project"
$script:ScopeExplicit = $false # Track if --global was explicitly passed
$script:InstallMcp = $true
$script:InstallSkills = $true
$script:Force = $false
$script:Silent = $false
$script:UserTools = ""
$script:Tools = ""
$script:UserMcpPath = ""
$script:Pkg = ""
$script:ProfileProvided = $false
$script:SkillsProfile = ""
$script:UserSkills = ""
$script:ListSkills = $false
# Databricks skills (bundled in repo)
$script:Skills = @(
"databricks-agent-bricks", "databricks-aibi-dashboards", "databricks-app-python",
"databricks-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-ai-functions",
"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)
$script:MlflowSkills = @(
"agent-evaluation", "analyze-mlflow-chat-session", "analyze-mlflow-trace",
"instrumenting-with-mlflow-tracing", "mlflow-onboarding", "querying-mlflow-metrics",
"retrieving-mlflow-traces", "searching-mlflow-docs"
)
$MlflowRawUrl = "https://raw.githubusercontent.com/mlflow/skills/main"
# APX skills (fetched from databricks-solutions/apx repo)
$script:ApxSkills = @("databricks-app-apx")
$ApxRawUrl = "https://raw.githubusercontent.com/databricks-solutions/apx/main/skills/apx"
# ─── Skill profiles ──────────────────────────────────────────
$script:CoreSkills = @("databricks-config", "databricks-docs", "databricks-python-sdk", "databricks-unity-catalog")
$script:ProfileDataEngineer = @(
"databricks-spark-declarative-pipelines", "databricks-spark-structured-streaming",
"databricks-jobs", "databricks-bundles", "databricks-dbsql", "databricks-iceberg",
"databricks-zerobus-ingest", "spark-python-data-source", "databricks-metric-views",
"databricks-synthetic-data-gen"
)
$script:ProfileAnalyst = @(
"databricks-aibi-dashboards", "databricks-dbsql", "databricks-genie", "databricks-metric-views"
)
$script:ProfileAiMlEngineer = @(
"databricks-agent-bricks", "databricks-vector-search", "databricks-model-serving",
"databricks-genie", "databricks-ai-functions", "databricks-unstructured-pdf-generation",
"databricks-mlflow-evaluation", "databricks-synthetic-data-gen", "databricks-jobs"
)
$script:ProfileAiMlMlflow = @(
"agent-evaluation", "analyze-mlflow-chat-session", "analyze-mlflow-trace",
"instrumenting-with-mlflow-tracing", "mlflow-onboarding", "querying-mlflow-metrics",
"retrieving-mlflow-traces", "searching-mlflow-docs"
)
$script:ProfileAppDeveloper = @(
"databricks-app-python", "databricks-app-apx", "databricks-lakebase-autoscale",
"databricks-lakebase-provisioned", "databricks-model-serving", "databricks-dbsql",
"databricks-jobs", "databricks-bundles"
)
# Selected skills (populated during profile selection)
$script:SelectedSkills = @()
$script:SelectedMlflowSkills = @()
$script:SelectedApxSkills = @()
# ─── --list-skills handler ────────────────────────────────────
if ($script:ListSkills) {
Write-Host ""
Write-Host "Available Skill Profiles" -ForegroundColor White
Write-Host "--------------------------------"
Write-Host ""
Write-Host " all " -ForegroundColor White -NoNewline; Write-Host "All 34 skills (default)"
Write-Host " data-engineer " -ForegroundColor White -NoNewline; Write-Host "Pipelines, Spark, Jobs, Streaming (14 skills)"
Write-Host " analyst " -ForegroundColor White -NoNewline; Write-Host "Dashboards, SQL, Genie, Metrics (8 skills)"
Write-Host " ai-ml-engineer " -ForegroundColor White -NoNewline; Write-Host "Agents, RAG, Vector Search, MLflow (17 skills)"
Write-Host " app-developer " -ForegroundColor White -NoNewline; Write-Host "Apps, Lakebase, Deployment (10 skills)"
Write-Host ""
Write-Host "Core Skills (always installed)" -ForegroundColor White
Write-Host "--------------------------------"
foreach ($s in $script:CoreSkills) { Write-Host " " -NoNewline; Write-Host "v" -ForegroundColor Green -NoNewline; Write-Host " $s" }
Write-Host ""
Write-Host "Data Engineer" -ForegroundColor White
Write-Host "--------------------------------"
foreach ($s in $script:ProfileDataEngineer) { Write-Host " $s" }
Write-Host ""
Write-Host "Business Analyst" -ForegroundColor White
Write-Host "--------------------------------"
foreach ($s in $script:ProfileAnalyst) { Write-Host " $s" }
Write-Host ""
Write-Host "AI/ML Engineer" -ForegroundColor White
Write-Host "--------------------------------"
foreach ($s in $script:ProfileAiMlEngineer) { Write-Host " $s" }
Write-Host " + MLflow skills:" -ForegroundColor DarkGray
foreach ($s in $script:ProfileAiMlMlflow) { Write-Host " $s" }
Write-Host ""
Write-Host "App Developer" -ForegroundColor White
Write-Host "--------------------------------"
foreach ($s in $script:ProfileAppDeveloper) { Write-Host " $s" }
Write-Host ""
Write-Host "MLflow Skills (from mlflow/skills repo)" -ForegroundColor White
Write-Host "--------------------------------"
foreach ($s in $script:MlflowSkills) { Write-Host " $s" }
Write-Host ""
Write-Host "APX Skills (from databricks-solutions/apx repo)" -ForegroundColor White
Write-Host "--------------------------------"
foreach ($s in $script:ApxSkills) { Write-Host " $s" }
Write-Host ""
Write-Host "Usage: .\install.ps1 --skills-profile data-engineer,ai-ml-engineer" -ForegroundColor DarkGray
Write-Host " .\install.ps1 --skills databricks-jobs,databricks-dbsql" -ForegroundColor DarkGray
Write-Host ""
return
}
# ─── Ensure tools are in PATH ────────────────────────────────
# Chocolatey-installed tools may not be in PATH for SSH sessions
$machinePath = [System.Environment]::GetEnvironmentVariable("Path", "Machine")
$userPath = [System.Environment]::GetEnvironmentVariable("Path", "User")
if ($machinePath -or $userPath) {
$env:Path = "$machinePath;$userPath;$env:Path"
# Deduplicate
$env:Path = (($env:Path -split ';' | Select-Object -Unique | Where-Object { $_ }) -join ';')
}
# ─── Output helpers ───────────────────────────────────────────
function Write-Msg { param([string]$Text) if (-not $script:Silent) { Write-Host " $Text" } }
function Write-Ok { param([string]$Text) if (-not $script:Silent) { Write-Host " " -NoNewline; Write-Host "v" -ForegroundColor Green -NoNewline; Write-Host " $Text" } }
function Write-Warn { param([string]$Text) if (-not $script:Silent) { Write-Host " " -NoNewline; Write-Host "!" -ForegroundColor Yellow -NoNewline; Write-Host " $Text" } }
function Write-Err {
param([string]$Text)
Write-Host " " -NoNewline; Write-Host "x" -ForegroundColor Red -NoNewline; Write-Host " $Text"
Write-Host ""
Write-Host " Press any key to exit..." -ForegroundColor DarkGray
try { $null = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown") } catch {}
exit 1
}
function Write-Step { param([string]$Text) if (-not $script:Silent) { Write-Host ""; Write-Host "$Text" -ForegroundColor White } }
# ─── Parse arguments ─────────────────────────────────────────
$i = 0
while ($i -lt $args.Count) {
switch ($args[$i]) {
{ $_ -in "-p", "--profile" } { $script:Profile_ = $args[$i + 1]; $script:ProfileProvided = $true; $i += 2 }
{ $_ -in "-g", "--global", "-Global" } { $script:Scope = "global"; $script:ScopeExplicit = $true; $i++ }
{ $_ -in "--skills-only", "-SkillsOnly" } { $script:InstallMcp = $false; $i++ }
{ $_ -in "--mcp-only", "-McpOnly" } { $script:InstallSkills = $false; $i++ }
{ $_ -in "--mcp-path", "-McpPath" } { $script:UserMcpPath = $args[$i + 1]; $i += 2 }
{ $_ -in "--silent", "-Silent" } { $script:Silent = $true; $i++ }
{ $_ -in "--tools", "-Tools" } { $script:UserTools = $args[$i + 1]; $i += 2 }
{ $_ -in "--skills-profile", "-SkillsProfile" } { $script:SkillsProfile = $args[$i + 1]; $i += 2 }
{ $_ -in "--skills", "-Skills" } { $script:UserSkills = $args[$i + 1]; $i += 2 }
{ $_ -in "--list-skills", "-ListSkills" } { $script:ListSkills = $true; $i++ }
{ $_ -in "-f", "--force", "-Force" } { $script:Force = $true; $i++ }
{ $_ -in "-h", "--help", "-Help" } {
Write-Host "Databricks AI Dev Kit Installer (Windows)"
Write-Host ""
Write-Host "Usage: irm https://raw.githubusercontent.com/databricks-solutions/ai-dev-kit/main/install.ps1 -OutFile install.ps1"
Write-Host " .\install.ps1 [OPTIONS]"
Write-Host ""
Write-Host "Options:"
Write-Host " -p, --profile NAME Databricks profile (default: DEFAULT)"
Write-Host " -g, --global Install globally for all projects"
Write-Host " --skills-only Skip MCP server setup"
Write-Host " --mcp-only Skip skills installation"
Write-Host " --mcp-path PATH Path to MCP server installation"
Write-Host " --silent Silent mode (no output except errors)"
Write-Host " --tools LIST Comma-separated: claude,cursor,copilot,codex,gemini,antigravity"
Write-Host " --skills-profile LIST Comma-separated profiles: all,data-engineer,analyst,ai-ml-engineer,app-developer"
Write-Host " --skills LIST Comma-separated skill names to install (overrides profile)"
Write-Host " --list-skills List available skills and profiles, then exit"
Write-Host " -f, --force Force reinstall"
Write-Host " -h, --help Show this help"
Write-Host ""
Write-Host "Environment Variables:"
Write-Host " AIDEVKIT_BRANCH Branch or tag to install (default: latest release)"
Write-Host " AIDEVKIT_HOME Installation directory (default: ~/.ai-dev-kit)"
Write-Host ""
Write-Host "Examples:"
Write-Host " # Basic installation"
Write-Host " irm https://raw.githubusercontent.com/databricks-solutions/ai-dev-kit/main/install.ps1 | iex"
Write-Host ""
Write-Host " # Download and run with options"
Write-Host " irm https://raw.githubusercontent.com/databricks-solutions/ai-dev-kit/main/install.ps1 -OutFile install.ps1"
Write-Host " .\install.ps1 -Global -Force"
Write-Host ""
Write-Host " # Specify profile and force reinstall"
Write-Host " .\install.ps1 -Profile DEFAULT -Force"
return
}
default { Write-Err "Unknown option: $($args[$i]) (use -h for help)"; $i++ }
}
}
# ─── Interactive helpers ──────────────────────────────────────
function Test-Interactive {
if ($script:Silent) { return $false }
try {
$host.UI.RawUI.KeyAvailable | Out-Null
return $true
} catch {
return $false
}
}
function Read-Prompt {
param([string]$PromptText, [string]$Default)
if ($script:Silent) { return $Default }
$isInteractive = Test-Interactive
if ($isInteractive) {
Write-Host " $PromptText [$Default]: " -NoNewline
$result = Read-Host
if ([string]::IsNullOrWhiteSpace($result)) { return $Default }
return $result
} else {
return $Default
}
}
# Interactive checkbox selector using arrow keys + space/enter
# Returns space-separated selected values
function Select-Checkbox {
param(
[array]$Items # Each: @{ Label; Value; State; Hint }
)
$count = $Items.Count
$cursor = 0
$states = @()
foreach ($item in $Items) {
$states += $item.State
}
$isInteractive = Test-Interactive
if (-not $isInteractive) {
# Fallback: show numbered list, accept comma-separated numbers
Write-Host ""
for ($j = 0; $j -lt $count; $j++) {
$mark = if ($states[$j]) { "[X]" } else { "[ ]" }
$hint = $Items[$j].Hint
Write-Host " $($j + 1). $mark $($Items[$j].Label) ($hint)"
}
Write-Host ""
Write-Host " Enter numbers to toggle (e.g. 1,3), or press Enter to accept defaults: " -NoNewline
$input_ = Read-Host
if (-not [string]::IsNullOrWhiteSpace($input_)) {
# Reset all states
for ($j = 0; $j -lt $count; $j++) { $states[$j] = $false }
$nums = $input_ -split ',' | ForEach-Object { $_.Trim() }
foreach ($n in $nums) {
$idx = [int]$n - 1
if ($idx -ge 0 -and $idx -lt $count) { $states[$idx] = $true }
}
}
$selected = @()
for ($j = 0; $j -lt $count; $j++) {
if ($states[$j]) { $selected += $Items[$j].Value }
}
return ($selected -join ' ')
}
# Full interactive mode
Write-Host ""
Write-Host " Up/Down navigate, Space toggle, Enter on Confirm to finish" -ForegroundColor DarkGray
Write-Host ""
$totalRows = $count + 2 # items + blank + Confirm
# Hide cursor
try { [Console]::CursorVisible = $false } catch {}
# Draw function — uses relative cursor movement to handle terminal scroll
$drawCheckbox = {
[Console]::SetCursorPosition(0, [Math]::Max(0, [Console]::CursorTop - $totalRows))
for ($j = 0; $j -lt $count; $j++) {
$line = " "
if ($j -eq $cursor) {
Write-Host " " -NoNewline
Write-Host ">" -ForegroundColor Blue -NoNewline
Write-Host " " -NoNewline
} else {
Write-Host " " -NoNewline
}
if ($states[$j]) {
Write-Host "[" -NoNewline
Write-Host "v" -ForegroundColor Green -NoNewline
Write-Host "]" -NoNewline
} else {
Write-Host "[ ]" -NoNewline
}
$padLabel = $Items[$j].Label.PadRight(16)
Write-Host " $padLabel " -NoNewline
if ($states[$j]) {
Write-Host $Items[$j].Hint -ForegroundColor Green -NoNewline
} else {
Write-Host $Items[$j].Hint -ForegroundColor DarkGray -NoNewline
}
# Clear rest of line
$pos = [Console]::CursorLeft
$remaining = [Console]::WindowWidth - $pos - 1
if ($remaining -gt 0) { Write-Host (' ' * $remaining) -NoNewline }
Write-Host ""
}
# Blank line
Write-Host (' ' * ([Console]::WindowWidth - 1))
# Confirm button
if ($cursor -eq $count) {
Write-Host " " -NoNewline
Write-Host ">" -ForegroundColor Blue -NoNewline
Write-Host " " -NoNewline
Write-Host "[ Confirm ]" -ForegroundColor Green -NoNewline
} else {
Write-Host " " -NoNewline
Write-Host "[ Confirm ]" -ForegroundColor DarkGray -NoNewline
}
$pos = [Console]::CursorLeft
$remaining = [Console]::WindowWidth - $pos - 1
if ($remaining -gt 0) { Write-Host (' ' * $remaining) -NoNewline }
Write-Host ""
}
# Initial draw — reserve lines first
for ($j = 0; $j -lt $totalRows; $j++) { Write-Host "" }
& $drawCheckbox
# Input loop
while ($true) {
$key = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
switch ($key.VirtualKeyCode) {
38 { # Up arrow
if ($cursor -gt 0) { $cursor-- }
}
40 { # Down arrow
if ($cursor -lt $count) { $cursor++ }
}
32 { # Space
if ($cursor -lt $count) {
$states[$cursor] = -not $states[$cursor]
}
}
13 { # Enter
if ($cursor -lt $count) {
$states[$cursor] = -not $states[$cursor]
} else {
# On Confirm — done
& $drawCheckbox
break
}
}
}
if ($key.VirtualKeyCode -eq 13 -and $cursor -eq $count) { break }
& $drawCheckbox
}
# Show cursor
try { [Console]::CursorVisible = $true } catch {}
$selected = @()
for ($j = 0; $j -lt $count; $j++) {
if ($states[$j]) { $selected += $Items[$j].Value }
}
return ($selected -join ' ')
}
# Interactive radio selector using arrow keys + enter
# Returns the selected value
function Select-Radio {
param(
[array]$Items # Each: @{ Label; Value; Selected; Hint }
)
$count = $Items.Count
$cursor = 0
$selected = 0
for ($j = 0; $j -lt $count; $j++) {
if ($Items[$j].Selected) { $selected = $j }
}
$isInteractive = Test-Interactive
if (-not $isInteractive) {
# Fallback: numbered list
Write-Host ""
for ($j = 0; $j -lt $count; $j++) {
$mark = if ($j -eq $selected) { "(*)" } else { "( )" }
$hint = $Items[$j].Hint
Write-Host " $($j + 1). $mark $($Items[$j].Label) $hint"
}
Write-Host ""
Write-Host " Enter number to select (or press Enter for default): " -NoNewline
$input_ = Read-Host
if (-not [string]::IsNullOrWhiteSpace($input_)) {
$idx = [int]$input_ - 1
if ($idx -ge 0 -and $idx -lt $count) { $selected = $idx }
}
return $Items[$selected].Value
}
# Full interactive mode
Write-Host ""
Write-Host " Up/Down navigate, Enter confirm" -ForegroundColor DarkGray
Write-Host ""
$totalRows = $count + 2 # items + blank + Confirm
try { [Console]::CursorVisible = $false } catch {}
# Draw function — uses relative cursor movement to handle terminal scroll
$drawRadio = {
[Console]::SetCursorPosition(0, [Math]::Max(0, [Console]::CursorTop - $totalRows))
for ($j = 0; $j -lt $count; $j++) {
if ($j -eq $cursor) {
Write-Host " " -NoNewline
Write-Host ">" -ForegroundColor Blue -NoNewline
Write-Host " " -NoNewline
} else {
Write-Host " " -NoNewline
}
if ($j -eq $selected) {
Write-Host "(*)" -ForegroundColor Green -NoNewline
} else {
Write-Host "( )" -ForegroundColor DarkGray -NoNewline
}
$padLabel = $Items[$j].Label.PadRight(20)
Write-Host " $padLabel " -NoNewline
if ($j -eq $selected) {
Write-Host $Items[$j].Hint -ForegroundColor Green -NoNewline
} else {
Write-Host $Items[$j].Hint -ForegroundColor DarkGray -NoNewline
}
$pos = [Console]::CursorLeft
$remaining = [Console]::WindowWidth - $pos - 1
if ($remaining -gt 0) { Write-Host (' ' * $remaining) -NoNewline }
Write-Host ""
}
Write-Host (' ' * ([Console]::WindowWidth - 1))
if ($cursor -eq $count) {
Write-Host " " -NoNewline
Write-Host ">" -ForegroundColor Blue -NoNewline
Write-Host " " -NoNewline
Write-Host "[ Confirm ]" -ForegroundColor Green -NoNewline
} else {
Write-Host " " -NoNewline
Write-Host "[ Confirm ]" -ForegroundColor DarkGray -NoNewline
}
$pos = [Console]::CursorLeft
$remaining = [Console]::WindowWidth - $pos - 1
if ($remaining -gt 0) { Write-Host (' ' * $remaining) -NoNewline }
Write-Host ""
}
# Reserve lines
for ($j = 0; $j -lt $totalRows; $j++) { Write-Host "" }
& $drawRadio
while ($true) {
$key = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
switch ($key.VirtualKeyCode) {
38 { if ($cursor -gt 0) { $cursor-- } }
40 { if ($cursor -lt $count) { $cursor++ } }
32 { # Space — select but keep browsing
if ($cursor -lt $count) { $selected = $cursor }
}
13 { # Enter — select and confirm
if ($cursor -lt $count) { $selected = $cursor }
& $drawRadio
break
}
}
if ($key.VirtualKeyCode -eq 13) { break }
& $drawRadio
}
try { [Console]::CursorVisible = $true } catch {}
return $Items[$selected].Value
}
# ─── Tool detection & selection ───────────────────────────────
function Invoke-DetectTools {
if (-not [string]::IsNullOrWhiteSpace($script:UserTools)) {
$script:Tools = $script:UserTools -replace ',', ' '
return
}
$hasClaude = $null -ne (Get-Command claude -ErrorAction SilentlyContinue)
$hasCursor = ($null -ne (Get-Command cursor -ErrorAction SilentlyContinue)) -or
(Test-Path "$env:LOCALAPPDATA\Programs\cursor\Cursor.exe")
$hasCodex = $null -ne (Get-Command codex -ErrorAction SilentlyContinue)
$hasCopilot = ($null -ne (Get-Command code -ErrorAction SilentlyContinue)) -or
(Test-Path "$env:LOCALAPPDATA\Programs\Microsoft VS Code\Code.exe")
$hasGemini = $null -ne (Get-Command gemini -ErrorAction SilentlyContinue)
$hasAntigravity = ($null -ne (Get-Command antigravity -ErrorAction SilentlyContinue)) -or
(Test-Path "$env:LOCALAPPDATA\Programs\Antigravity\Antigravity.exe")
$claudeState = $hasClaude; $claudeHint = if ($hasClaude) { "detected" } else { "not found" }
$cursorState = $hasCursor; $cursorHint = if ($hasCursor) { "detected" } else { "not found" }
$codexState = $hasCodex; $codexHint = if ($hasCodex) { "detected" } else { "not found" }
$copilotState = $hasCopilot; $copilotHint = if ($hasCopilot) { "detected" } else { "not found" }
$geminiState = $hasGemini; $geminiHint = if ($hasGemini) { "detected" } else { "not found" }
$antigravityState = $hasAntigravity; $antigravityHint = if ($hasAntigravity) { "detected" } else { "not found" }
# If nothing detected, default to claude
if (-not $hasClaude -and -not $hasCursor -and -not $hasCodex -and -not $hasCopilot -and -not $hasGemini -and -not $hasAntigravity) {
$claudeState = $true
$claudeHint = "default"
}
if (-not $script:Silent) {
Write-Host ""
Write-Host " Select tools to install for:" -ForegroundColor White
}
$items = @(
@{ Label = "Claude Code"; Value = "claude"; State = $claudeState; Hint = $claudeHint }
@{ Label = "Cursor"; Value = "cursor"; State = $cursorState; Hint = $cursorHint }
@{ Label = "GitHub Copilot"; Value = "copilot"; State = $copilotState; Hint = $copilotHint }
@{ Label = "OpenAI Codex"; Value = "codex"; State = $codexState; Hint = $codexHint }
@{ Label = "Gemini CLI"; Value = "gemini"; State = $geminiState; Hint = $geminiHint }
@{ Label = "Antigravity"; Value = "antigravity"; State = $antigravityState; Hint = $antigravityHint }
)
$result = Select-Checkbox -Items $items
if ([string]::IsNullOrWhiteSpace($result)) {
Write-Warn "No tools selected, defaulting to Claude Code"
$result = "claude"
}
$script:Tools = $result
}
# ─── Databricks profile selection ────────────────────────────
function Invoke-PromptProfile {
if ($script:ProfileProvided) { return }
if ($script:Silent) { return }
$cfgFile = Join-Path $env:USERPROFILE ".databrickscfg"
$profiles = @()
if (Test-Path $cfgFile) {
$lines = Get-Content $cfgFile
foreach ($line in $lines) {
if ($line -match '^\[([a-zA-Z0-9_-]+)\]$') {
$profiles += $Matches[1]
}
}
}
Write-Host ""
Write-Host " Select Databricks profile" -ForegroundColor White
if ($profiles.Count -gt 0) {
$items = @()
$hasDefault = $profiles -contains "DEFAULT"
foreach ($p in $profiles) {
$sel = $false
$hint = ""
if ($p -eq "DEFAULT") { $sel = $true; $hint = "default" }
$items += @{ Label = $p; Value = $p; Selected = $sel; Hint = $hint }
}
# Add custom profile option at the end
$items += @{ Label = "Custom profile name..."; Value = "__CUSTOM__"; Selected = $false; Hint = "Enter a custom profile name" }
if (-not $hasDefault -and $items.Count -gt 1) {
$items[0].Selected = $true
}
$selectedProfile = Select-Radio -Items $items
# If custom was selected, prompt for name
if ($selectedProfile -eq "__CUSTOM__") {
Write-Host ""
$script:Profile_ = Read-Prompt -PromptText "Enter profile name" -Default "DEFAULT"
} else {
$script:Profile_ = $selectedProfile
}
} else {
Write-Host " No ~/.databrickscfg found. You can authenticate after install." -ForegroundColor DarkGray
Write-Host ""
$script:Profile_ = Read-Prompt -PromptText "Profile name" -Default "DEFAULT"
}
}
# ─── MCP path selection ──────────────────────────────────────
function Invoke-PromptMcpPath {
if (-not [string]::IsNullOrWhiteSpace($script:UserMcpPath)) {
$script:InstallDir = $script:UserMcpPath
} elseif (-not $script:Silent) {
Write-Host ""
Write-Host " MCP server location" -ForegroundColor White
Write-Host " The MCP server runtime (Python venv + source) will be installed here." -ForegroundColor DarkGray
Write-Host " Shared across all your projects -- only the config files are per-project." -ForegroundColor DarkGray
Write-Host ""
$selected = Read-Prompt -PromptText "Install path" -Default $InstallDir
$script:InstallDir = $selected
}
# Update derived paths
$script:RepoDir = Join-Path $script:InstallDir "repo"
$script:VenvDir = Join-Path $script:InstallDir ".venv"
$script:VenvPython = Join-Path $script:VenvDir "Scripts\python.exe"
$script:McpEntry = Join-Path $script:RepoDir "databricks-mcp-server\run_server.py"
}
# ─── Check prerequisites ─────────────────────────────────────
function Test-Dependencies {
# Git
if (-not (Get-Command git -ErrorAction SilentlyContinue)) {
Write-Err "git required. Install: choco install git -y"
}
Write-Ok "git"
# Databricks CLI
if (Get-Command databricks -ErrorAction SilentlyContinue) {
try {
$cliOutput = & databricks --version 2>&1
if ($cliOutput -match '(\d+\.\d+\.\d+)') {
$cliVersion = $Matches[1]
if ([version]$cliVersion -ge [version]$MinCliVersion) {
Write-Ok "Databricks CLI v$cliVersion"
} else {
Write-Warn "Databricks CLI v$cliVersion is outdated (minimum: v$MinCliVersion)"
Write-Msg " Upgrade: winget upgrade Databricks.DatabricksCLI"
}
} else {
Write-Warn "Could not determine Databricks CLI version"
}
} catch {
Write-Warn "Could not determine Databricks CLI version"
}
} else {
Write-Warn "Databricks CLI not found. Install: winget install Databricks.DatabricksCLI"
Write-Msg "You can still install, but authentication will require the CLI later."
}
# Python package manager
if ($script:InstallMcp) {
if (Get-Command uv -ErrorAction SilentlyContinue) {
$script:Pkg = "uv"
} elseif (Get-Command pip3 -ErrorAction SilentlyContinue) {
$script:Pkg = "pip3"
} elseif (Get-Command pip -ErrorAction SilentlyContinue) {
$script:Pkg = "pip"
} else {
Write-Err "Python package manager required. Install Python: choco install python -y"
}
Write-Ok $script:Pkg
}
}
# ─── Check version ───────────────────────────────────────────
function Test-Version {
$verFile = Join-Path $script:InstallDir "version"
if ($script:Scope -eq "project") {
$verFile = Join-Path (Get-Location) ".ai-dev-kit\version"
}
if (-not (Test-Path $verFile)) { return }
if ($script:Force) { return }
# Skip version gate if user explicitly wants a different skill profile
if (-not [string]::IsNullOrWhiteSpace($script:SkillsProfile) -or -not [string]::IsNullOrWhiteSpace($script:UserSkills)) {
$savedProfileFile = Join-Path $script:StateDir ".skills-profile"
if (-not (Test-Path $savedProfileFile) -and $script:Scope -eq "project") {
$savedProfileFile = Join-Path $script:InstallDir ".skills-profile"
}
if (Test-Path $savedProfileFile) {
$savedProfile = (Get-Content $savedProfileFile -Raw).Trim()
$requested = if (-not [string]::IsNullOrWhiteSpace($script:UserSkills)) { "custom:$($script:UserSkills)" } else { $script:SkillsProfile }
if ($savedProfile -ne $requested) { return }
}
}
$localVer = (Get-Content $verFile -Raw).Trim()
try {
$remoteVer = (Invoke-WebRequest -Uri "$RawUrl/VERSION" -UseBasicParsing -ErrorAction Stop).Content.Trim()
} catch {
return
}
if ($remoteVer -and $remoteVer -notmatch '(404|Not Found|error)') {
if ($localVer -eq $remoteVer) {
Write-Ok "Already up to date (v$localVer)"
Write-Msg "Use --force to reinstall or --skills-profile to change profiles"
exit 0
}
}
}
# ─── Setup MCP server ────────────────────────────────────────
function Install-McpServer {
Write-Step "Setting up MCP server"
# Native commands (git, pip) write informational messages to stderr.
# Temporarily relax error handling so these don't terminate the script.
$prevEAP = $ErrorActionPreference
$ErrorActionPreference = "Continue"
# Clone or update repo
if (Test-Path (Join-Path $script:RepoDir ".git")) {
& git -C $script:RepoDir fetch -q --depth 1 origin $Branch 2>&1 | Out-Null
& git -C $script:RepoDir reset --hard FETCH_HEAD 2>&1 | Out-Null
if ($LASTEXITCODE -ne 0) {
Remove-Item -Recurse -Force $script:RepoDir -ErrorAction SilentlyContinue
& git -c advice.detachedHead=false clone -q --depth 1 --branch $Branch $RepoUrl $script:RepoDir 2>&1 | Out-Null
}
} else {
if (-not (Test-Path $script:InstallDir)) {
New-Item -ItemType Directory -Path $script:InstallDir -Force | Out-Null
}
& git -c advice.detachedHead=false clone -q --depth 1 --branch $Branch $RepoUrl $script:RepoDir 2>&1 | Out-Null
}
if ($LASTEXITCODE -ne 0) {
$ErrorActionPreference = $prevEAP
Write-Err "Failed to clone repository"
}
Write-Ok "Repository cloned ($Branch)"
# Create venv and install
Write-Msg "Installing Python dependencies..."
if ($script:Pkg -eq "uv") {
& uv venv --python 3.11 --allow-existing $script:VenvDir -q 2>&1 | Out-Null
if ($LASTEXITCODE -ne 0) {
& uv venv --allow-existing $script:VenvDir -q 2>&1 | Out-Null
}
& uv pip install --python $script:VenvPython -e "$($script:RepoDir)\databricks-tools-core" -e "$($script:RepoDir)\databricks-mcp-server" -q 2>&1 | Out-Null
} else {
if (-not (Test-Path $script:VenvDir)) {
& python -m venv $script:VenvDir 2>&1 | Out-Null
}
& $script:VenvPython -m pip install -q -e "$($script:RepoDir)\databricks-tools-core" -e "$($script:RepoDir)\databricks-mcp-server" 2>&1 | Out-Null
}
# Verify
& $script:VenvPython -c "import databricks_mcp_server" 2>&1 | Out-Null
if ($LASTEXITCODE -ne 0) {
$ErrorActionPreference = $prevEAP
Write-Err "MCP server install failed"
}
$ErrorActionPreference = $prevEAP
Write-Ok "MCP server ready"
# Check Databricks SDK version
try {
$sdkOutput = & $script:VenvPython -c "from databricks.sdk.version import __version__; print(__version__)" 2>&1
if ($sdkOutput -match '(\d+\.\d+\.\d+)') {
$sdkVersion = $Matches[1]
if ([version]$sdkVersion -ge [version]$MinSdkVersion) {
Write-Ok "Databricks SDK v$sdkVersion"
} else {
Write-Warn "Databricks SDK v$sdkVersion is outdated (minimum: v$MinSdkVersion)"
Write-Msg " Upgrade: $($script:VenvPython) -m pip install --upgrade databricks-sdk"
}
} else {
Write-Warn "Could not determine Databricks SDK version"
}
} catch {
Write-Warn "Could not determine Databricks SDK version"
}
}
# ─── Skill profile selection ──────────────────────────────────
function Resolve-Skills {
# Priority 1: Explicit --skills flag
if (-not [string]::IsNullOrWhiteSpace($script:UserSkills)) {
$userList = $script:UserSkills -split ','
$dbSkills = @() + $script:CoreSkills
$mlflowSkills = @()
$apxSkills = @()
foreach ($skill in $userList) {
$skill = $skill.Trim()
if ($script:MlflowSkills -contains $skill) {
$mlflowSkills += $skill
} elseif ($script:ApxSkills -contains $skill) {
$apxSkills += $skill
} else {
$dbSkills += $skill
}
}
$script:SelectedSkills = $dbSkills | Select-Object -Unique
$script:SelectedMlflowSkills = $mlflowSkills | Select-Object -Unique
$script:SelectedApxSkills = $apxSkills | Select-Object -Unique
return
}
# Priority 2: --skills-profile flag or interactive selection
if ([string]::IsNullOrWhiteSpace($script:SkillsProfile) -or $script:SkillsProfile -eq "all") {
$script:SelectedSkills = $script:Skills
$script:SelectedMlflowSkills = $script:MlflowSkills
$script:SelectedApxSkills = $script:ApxSkills
return
}
# Build union of selected profiles
$dbSkills = @() + $script:CoreSkills
$mlflowSkills = @()
$apxSkills = @()
foreach ($profile in ($script:SkillsProfile -split ',')) {
$profile = $profile.Trim()
switch ($profile) {
"all" {
$script:SelectedSkills = $script:Skills
$script:SelectedMlflowSkills = $script:MlflowSkills
$script:SelectedApxSkills = $script:ApxSkills
return
}
"data-engineer" { $dbSkills += $script:ProfileDataEngineer }
"analyst" { $dbSkills += $script:ProfileAnalyst }
"ai-ml-engineer" {
$dbSkills += $script:ProfileAiMlEngineer
$mlflowSkills += $script:ProfileAiMlMlflow
}
"app-developer" {
$dbSkills += $script:ProfileAppDeveloper
$apxSkills += $script:ApxSkills
}
default { Write-Warn "Unknown skill profile: $profile (ignored)" }
}
}
$script:SelectedSkills = $dbSkills | Select-Object -Unique
$script:SelectedMlflowSkills = $mlflowSkills | Select-Object -Unique
$script:SelectedApxSkills = $apxSkills | Select-Object -Unique
}
function Invoke-PromptSkillsProfile {
# If provided via --skills or --skills-profile, skip interactive prompt
if (-not [string]::IsNullOrWhiteSpace($script:UserSkills) -or -not [string]::IsNullOrWhiteSpace($script:SkillsProfile)) {
return
}
# Skip in silent mode
if ($script:Silent) {
$script:SkillsProfile = "all"
return
}
# Check for previous selection (scope-local first, then global fallback for upgrades)
$profileFile = Join-Path $script:StateDir ".skills-profile"
if (-not (Test-Path $profileFile) -and $script:Scope -eq "project") {
$profileFile = Join-Path $script:InstallDir ".skills-profile"
}
if (Test-Path $profileFile) {
$prevProfile = (Get-Content $profileFile -Raw).Trim()
if (-not $script:Force) {
Write-Host ""
$displayProfile = $prevProfile -replace ',', ', '
$keep = Read-Prompt -PromptText "Previous skill profile: $displayProfile. Keep? (Y/n)" -Default "y"
if ($keep -in @("y", "Y", "yes", "")) {
$script:SkillsProfile = $prevProfile
return
}
}
}
Write-Host ""
Write-Host " Select skill profile(s)" -ForegroundColor White
# Custom checkbox with mutual exclusion: "All" deselects others, others deselect "All"
$pLabels = @("All Skills", "Data Engineer", "Business Analyst", "AI/ML Engineer", "App Developer", "Custom")
$pValues = @("all", "data-engineer", "analyst", "ai-ml-engineer", "app-developer", "custom")
$pHints = @("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")
$pStates = @($true, $false, $false, $false, $false, $false)
$pCount = 6
$pCursor = 0
$pTotalRows = $pCount + 2
$isInteractive = Test-Interactive
if (-not $isInteractive) {
# Fallback: numbered list
Write-Host ""
for ($j = 0; $j -lt $pCount; $j++) {
$mark = if ($pStates[$j]) { "[X]" } else { "[ ]" }
Write-Host " $($j + 1). $mark $($pLabels[$j]) ($($pHints[$j]))"
}
Write-Host ""
Write-Host " Enter numbers to toggle (e.g. 2,4), or press Enter for All: " -NoNewline
$input_ = Read-Host
if (-not [string]::IsNullOrWhiteSpace($input_)) {
for ($j = 0; $j -lt $pCount; $j++) { $pStates[$j] = $false }
$nums = $input_ -split ',' | ForEach-Object { $_.Trim() }
foreach ($n in $nums) {
$idx = [int]$n - 1
if ($idx -ge 0 -and $idx -lt $pCount) { $pStates[$idx] = $true }
}
}
} else {
Write-Host ""
Write-Host " Up/Down navigate, Space toggle, Enter on Confirm to finish" -ForegroundColor DarkGray
Write-Host ""
try { [Console]::CursorVisible = $false } catch {}
$drawProfiles = {
[Console]::SetCursorPosition(0, [Math]::Max(0, [Console]::CursorTop - $pTotalRows))
for ($j = 0; $j -lt $pCount; $j++) {
if ($j -eq $pCursor) {
Write-Host " " -NoNewline; Write-Host ">" -ForegroundColor Blue -NoNewline; Write-Host " " -NoNewline
} else {
Write-Host " " -NoNewline
}
if ($pStates[$j]) {
Write-Host "[" -NoNewline; Write-Host "v" -ForegroundColor Green -NoNewline; Write-Host "]" -NoNewline
} else {
Write-Host "[ ]" -NoNewline
}
$padLabel = $pLabels[$j].PadRight(20)
Write-Host " $padLabel " -NoNewline
if ($pStates[$j]) {
Write-Host $pHints[$j] -ForegroundColor Green -NoNewline
} else {
Write-Host $pHints[$j] -ForegroundColor DarkGray -NoNewline
}
$pos = [Console]::CursorLeft
$remaining = [Console]::WindowWidth - $pos - 1
if ($remaining -gt 0) { Write-Host (' ' * $remaining) -NoNewline }