-
Notifications
You must be signed in to change notification settings - Fork 405
Expand file tree
/
Copy pathinstall.ps1
More file actions
2968 lines (2688 loc) · 144 KB
/
Copy pathinstall.ps1
File metadata and controls
2968 lines (2688 loc) · 144 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 Databricks skills and configuration for Claude Code, Cursor, OpenAI Codex, GitHub Copilot, Gemini CLI, Antigravity, Windsurf, OpenCode, and Kiro.
#
# The (deprecated, optional) MCP server has its own installer:
# databricks-mcp-server\mcp_install.ps1 (Windows)
# databricks-mcp-server/mcp_install.sh (macOS/Linux)
#
# 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
#
# # 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. AIDEVKIT_BRANCH is canonical here; DEVKIT_BRANCH
# is accepted as an alias so the bash and PowerShell installers honor the same var.
# $script:BranchExplicit tracks whether the user asked for a specific ref (vs the
# auto-resolved latest release) — an explicit ref triggers the branch hand-off.
$script:BranchExplicit = [bool]($env:AIDEVKIT_BRANCH -or $env:DEVKIT_BRANCH)
if ($env:AIDEVKIT_BRANCH -or $env:DEVKIT_BRANCH) {
$Branch = if ($env:AIDEVKIT_BRANCH) { $env:AIDEVKIT_BRANCH } else { $env:DEVKIT_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"
}
}
$RawUrl = "https://raw.githubusercontent.com/$Owner/$Repo/$Branch"
$InstallDir = if ($env:AIDEVKIT_HOME) { $env:AIDEVKIT_HOME } else { Join-Path $env:USERPROFILE ".ai-dev-kit" }
# Minimum required versions
$MinCliVersion = "0.278.0"
# Agent skills are delegated to `databricks aitools`, which ships with CLI v1.0.0+
$MinAitoolsCliVersion = "1.0.0"
# ─── Defaults ─────────────────────────────────────────────────
# DEVKIT_* env vars mirror the bash installer so both honor the same config.
$script:Profile_ = if ($env:DEVKIT_PROFILE) { $env:DEVKIT_PROFILE } else { "DEFAULT" }
$script:Scope = if ($env:DEVKIT_SCOPE) { $env:DEVKIT_SCOPE } else { "project" }
$script:ScopeExplicit = [bool]$env:DEVKIT_SCOPE # Track if scope was explicitly set
# This installer sets up skills only. The (deprecated, optional) MCP server has
# moved to its own installer: databricks-mcp-server\mcp_install.ps1.
$script:InstallSkills = $true
$script:Force = ($env:DEVKIT_FORCE -in @("true", "1"))
$script:Silent = ($env:DEVKIT_SILENT -in @("true", "1"))
$script:UserTools = if ($env:DEVKIT_TOOLS) { $env:DEVKIT_TOOLS } else { "" }
$script:Tools = ""
$script:ProfileProvided = [bool]$env:DEVKIT_PROFILE
$script:SkillsProfile = if ($env:DEVKIT_SKILLS_PROFILE) { $env:DEVKIT_SKILLS_PROFILE } else { "" }
$script:UserSkills = if ($env:DEVKIT_SKILLS) { $env:DEVKIT_SKILLS } else { "" }
$script:ListSkills = $false
$script:DryRun = ($env:DRY_RUN -in @("true", "1"))
$script:Uninstall = $false
$script:AssumeYes = $false
# Include experimental agent skills in profile/"all" selections (default: true).
# Pass --experimental false (or DEVKIT_EXPERIMENTAL=false) for stable only.
# Explicit --skills requests are always honored as named.
$script:InstallExperimental = ($env:DEVKIT_EXPERIMENTAL -notin @("false", "0"))
# Raw-fetch ref override for MLflow skills (mlflow/skills is tagless -- main is intentional)
$script:MlflowRef = if ($env:MLFLOW_REF) { $env:MLFLOW_REF } else { "main" }
$script:IncludePrereleases = ($env:INCLUDE_PRERELEASES -in @("true", "1"))
# MLflow skills (fetched from mlflow/skills repo; MLFLOW_REF defaults to main -- the repo is tagless)
$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"
)
$MlflowBaseUrl = "https://raw.githubusercontent.com/mlflow/skills"
# Agent skills (from databricks/databricks-agent-skills, installed and managed by
# `databricks aitools`, which ships with the Databricks CLI v1.0.0+).
# The live inventory is discovered at runtime via `databricks aitools list -o json`
# (see Get-AgentBInventory); these lists are the fallback snapshot (v0.2.10),
# used only when the CLI is unavailable/offline.
$script:AgentBStableFallback = @(
"databricks-agent-bricks", "databricks-ai-functions", "databricks-aibi-dashboards",
"databricks-app-design", "databricks-apps", "databricks-apps-python",
"databricks-core", "databricks-dabs", "databricks-data-discovery",
"databricks-dbsql", "databricks-docs", "databricks-execution-compute",
"databricks-iceberg", "databricks-jobs", "databricks-lakebase",
"databricks-lakeflow-connect", "databricks-metric-views", "databricks-ml-training",
"databricks-mlflow-evaluation", "databricks-model-serving", "databricks-pipelines",
"databricks-python-sdk", "databricks-serverless-migration",
"databricks-spark-structured-streaming", "databricks-synthetic-data-gen",
"databricks-unity-catalog", "databricks-unstructured-pdf-generation",
"databricks-vector-search", "databricks-zerobus-ingest"
)
$script:AgentBExperimentalFallback = @(
"databricks-ai-runtime", "databricks-genie", "spark-python-data-source"
)
# Skills never installed by default (excluded from "all" and profile selections;
# still installable via an explicit --skills request). Empty = none.
# NOTE: keep this empty unless a skill genuinely shouldn't ship by default -- the
# native "all" install (Install-AgentBAll) runs `databricks aitools install` with
# no --skills filter, so it does NOT honor this list. Excluding a name here only
# shrinks the displayed count/selection, making it disagree with what the "all"
# path actually installs. (databricks-execution-compute was removed: it's a
# first-class stable skill in the databricks-agent-skills manifest.)
$script:AgentBExcluded = @()
# Populated by Get-AgentBInventory (live or fallback)
$script:AgentBStable = @()
$script:AgentBExperimental = @()
$script:AgentBRelease = ""
# Old skill names -> new names (breaking rename when sourcing moved to
# databricks-agent-skills). Explicit requests for old names are migrated with a warning.
$script:RenamedSkills = @{
"databricks-bundles" = "databricks-dabs"
"databricks-spark-declarative-pipelines" = "databricks-pipelines"
"databricks-config" = "databricks-core"
"databricks" = "databricks-core"
"databricks-lakebase-autoscale" = "databricks-lakebase"
"databricks-lakebase-provisioned" = "databricks-lakebase"
"databricks-genie" = "databricks-genie-agents"
}
# ─── Skill profiles ──────────────────────────────────────────
# Core skills always installed regardless of profile selection (all from databricks-agent-skills)
$script:CoreSkills = @("databricks-core", "databricks-docs", "databricks-python-sdk", "databricks-unity-catalog")
# Profile definitions (non-core skills only -- core skills are always added).
# Names may come from any source; Resolve-Skills buckets them.
$script:ProfileDataEngineer = @(
"databricks-pipelines", "databricks-spark-structured-streaming", "databricks-jobs",
"databricks-dabs", "databricks-dbsql", "databricks-iceberg", "databricks-lakeflow-connect",
"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-ai-functions", "databricks-vector-search",
"databricks-model-serving", "databricks-genie", "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-apps", "databricks-apps-python", "databricks-lakebase",
"databricks-model-serving", "databricks-dbsql", "databricks-jobs", "databricks-dabs"
)
# Selected skills (populated during profile selection)
$script:SelectedMlflowSkills = @()
$script:SelectedAgentBSkills = @()
# True when the user selected *all* agent skills (the "all" profile). In that case
# we skip the fragile per-skill enumeration and let `databricks aitools install`
# define the full set itself (its native default = every stable skill; add
# --experimental for the rest). A partial selection (a profile subset or --skills)
# keeps the enumerated --skills path.
$script:SelectedAllAgentB = $false
# Resolved raw-fetch refs (populated by Resolve-FetchRefs)
$script:MlflowResolvedRef = ""
# aitools agent mapping (populated by Resolve-AitoolsAgents)
$script:AitoolsAgents = ""
# ─── --list-skills handler ────────────────────────────────────
# (function -- needs Get-AgentBInventory; invoked from Invoke-Main)
# Number of skills the "all" profile installs (excluded agent skills omitted)
function Get-AllSkillsCount {
$n = $script:MlflowSkills.Count +
$script:AgentBStable.Count + $script:AgentBExperimental.Count
foreach ($skill in $script:AgentBExcluded) {
if (($script:AgentBStable -contains $skill) -or ($script:AgentBExperimental -contains $skill)) { $n-- }
}
return $n
}
function Show-SkillsList {
Get-AgentBInventory
$allCount = Get-AllSkillsCount
$deCount = $script:CoreSkills.Count + $script:ProfileDataEngineer.Count
$anCount = $script:CoreSkills.Count + $script:ProfileAnalyst.Count
$aiCount = $script:CoreSkills.Count + $script:ProfileAiMlEngineer.Count + $script:ProfileAiMlMlflow.Count
$apCount = $script:CoreSkills.Count + $script:ProfileAppDeveloper.Count
Write-Host ""
Write-Host "Available Skill Profiles" -ForegroundColor White
Write-Host "--------------------------------"
Write-Host ""
Write-Host " all " -ForegroundColor White -NoNewline; Write-Host "All $allCount skills (default)"
Write-Host " data-engineer " -ForegroundColor White -NoNewline; Write-Host "Pipelines, Spark, Jobs, Streaming ($deCount skills)"
Write-Host " analyst " -ForegroundColor White -NoNewline; Write-Host "Dashboards, SQL, Genie, Metrics ($anCount skills)"
Write-Host " ai-ml-engineer " -ForegroundColor White -NoNewline; Write-Host "Agents, RAG, Vector Search, MLflow ($aiCount skills)"
Write-Host " app-developer " -ForegroundColor White -NoNewline; Write-Host "Apps, Lakebase, Deployment ($apCount 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 @ $($script:MlflowRef))" -ForegroundColor White
Write-Host "--------------------------------"
foreach ($s in $script:MlflowSkills) { Write-Host " $s" }
Write-Host ""
$releaseSuffix = if ($script:AgentBRelease) { " @ $($script:AgentBRelease)" } else { "" }
Write-Host "Agent Skills (from databricks/databricks-agent-skills$releaseSuffix -- managed by databricks aitools)" -ForegroundColor White
Write-Host "--------------------------------"
foreach ($s in $script:AgentBStable) { Write-Host " $s" }
Write-Host " experimental:" -ForegroundColor DarkGray
foreach ($s in $script:AgentBExperimental) {
if ($script:AgentBExcluded -contains $s) {
Write-Host " $s (excluded by default -- request explicitly via --skills)" -ForegroundColor DarkGray
} else {
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 ""
}
# ─── 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 } }
# Deprecation notice for the removed MCP flags/env. Always written to stderr
# (even in silent mode) since the user explicitly passed a now-removed option.
function Show-McpMovedNotice {
[Console]::Error.WriteLine(" ! MCP setup has moved out of this installer. Run databricks-mcp-server\mcp_install.ps1 (or mcp_install.sh on macOS/Linux) to install and register the Databricks MCP server.")
}
# ─── Parse arguments ─────────────────────────────────────────
$i = 0
while ($i -lt $args.Count) {
switch ($args[$i]) {
{ $_ -in "-b", "--branch", "-Branch" } { $Branch = $args[$i + 1]; $script:BranchExplicit = $true; $RawUrl = "https://raw.githubusercontent.com/$Owner/$Repo/$Branch"; $i += 2 }
{ $_ -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" } { $i++ } # accepted for backward compat (skills-only is now the only mode)
# Removed MCP flags — handled gracefully. --mcp warns and continues with
# the normal (skills-only) install; --mcp-path also consumes its value so
# arg-parsing doesn't choke on the now-unknown argument.
{ $_ -in "--mcp", "-Mcp" } { Show-McpMovedNotice; $i++ }
{ $_ -in "--mcp-path", "-McpPath" } { Show-McpMovedNotice; $i += 2 }
# --mcp-only had no non-MCP work to do, so just point the user and exit
# cleanly (informative, not a crash).
{ $_ -in "--mcp-only", "-McpOnly" } { Show-McpMovedNotice; exit 0 }
{ $_ -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 "--experimental", "-Experimental" } {
switch ("$($args[$i + 1])".ToLower()) {
{ $_ -in "false", "0" } { $script:InstallExperimental = $false; $i += 2 }
{ $_ -in "true", "1" } { $script:InstallExperimental = $true; $i += 2 }
default { $script:InstallExperimental = $true; $i++ }
}
}
{ $_ -in "--dry-run", "-DryRun" } { $script:DryRun = $true; $i++ }
{ $_ -in "-f", "--force", "-Force" } { $script:Force = $true; $i++ }
{ $_ -in "--uninstall", "-Uninstall" } { $script:Uninstall = $true; $i++ }
{ $_ -in "-y", "--yes", "-Yes" } { $script:AssumeYes = $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 " -b, --branch NAME Install a specific release/branch (runs that version's own installer)"
Write-Host " -p, --profile NAME Databricks profile (default: DEFAULT)"
Write-Host " -g, --global Install globally for all projects"
Write-Host " --silent Silent mode (no output except errors)"
Write-Host " --tools LIST Comma-separated: claude,cursor,copilot,codex,gemini,antigravity,windsurf,opencode,kiro"
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 " --experimental BOOL Include experimental agent skills (default: true; 'false' = stable only)"
Write-Host " --dry-run Print what would be installed (resolved refs, aitools command) and exit"
Write-Host " -f, --force Force reinstall"
Write-Host " --uninstall Remove AI Dev Kit: skills, Claude Code plugin, and any leftover MCP config from older installs"
Write-Host " --dry-run With --uninstall: print what would be removed, change nothing"
Write-Host " -y, --yes With --uninstall: skip the confirmation prompt"
Write-Host " -h, --help Show this help"
Write-Host ""
Write-Host "Environment Variables:"
Write-Host " AIDEVKIT_BRANCH Branch or tag to install (alias: DEVKIT_BRANCH; default: latest release)"
Write-Host " AIDEVKIT_HOME Installation directory (default: ~/.ai-dev-kit)"
Write-Host " DEVKIT_PROFILE/SCOPE/TOOLS/SKILLS/SKILLS_PROFILE/FORCE/SILENT (mirror the bash installer)"
Write-Host " DEVKIT_EXPERIMENTAL 'true' (default) or 'false' to skip experimental agent skills"
Write-Host " MLFLOW_REF Ref for MLflow skills fetch (default: main)"
Write-Host " DRY_RUN Set to '1' to print the install plan and exit"
Write-Host ""
Write-Host "Notes:"
Write-Host " Most Databricks skills are installed via 'databricks aitools' (Databricks CLI v1.0.0+)"
Write-Host " and are updated/uninstalled with 'databricks aitools update|uninstall', not this script."
Write-Host " The MCP server is deprecated/optional and has its own installer:"
Write-Host " .\databricks-mcp-server\mcp_install.ps1 (or mcp_install.sh on macOS/Linux)."
Write-Host " Renamed skills: databricks-bundles -> databricks-dabs,"
Write-Host " databricks-spark-declarative-pipelines -> databricks-pipelines."
Write-Host " Replaced skills: databricks-config -> databricks-core,"
Write-Host " databricks-lakebase-autoscale/provisioned -> databricks-lakebase."
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)" }
}
}
# Removed MCP env var — warn and continue with the normal (skills-only) install.
if ($env:DEVKIT_INSTALL_MCP -in @("true", "1")) {
Show-McpMovedNotice
}
# ─── --uninstall ───────────────────────────────────────────────
# Every skill directory name ever shipped (current + historical renames/removals),
# so old installs — e.g. the removed databricks-lakebase-provisioned or renamed
# databricks-app-python — are swept, not just the current release's skills.
$script:UninstallSkillNames = @(
"databricks-agent-bricks","databricks-ai-functions","databricks-aibi-dashboards",
"databricks-bundles","databricks-asset-bundles","databricks-apps-python","databricks-app-python",
"databricks-app-apx","databricks-config","databricks-dbsql","databricks-docs",
"databricks-execution-compute","databricks-genie","databricks-iceberg","databricks-jobs",
"databricks-lakebase-autoscale","databricks-lakebase-provisioned","databricks-metric-views",
"databricks-ml-training-serving","databricks-model-serving","databricks-mlflow-evaluation",
"databricks-parsing","databricks-python-sdk","databricks-spark-declarative-pipelines",
"databricks-spark-structured-streaming","databricks-synthetic-data-gen","databricks-synthetic-data-generation",
"databricks-unity-catalog","databricks-unstructured-pdf-generation","databricks-vector-search",
"databricks-zerobus-ingest","spark-python-data-source",
"databricks","databricks-apps","databricks-lakebase",
"agent-evaluation","analyze-mlflow-chat-session","analyze-mlflow-trace",
"instrumenting-with-mlflow-tracing","mlflow-onboarding","querying-mlflow-metrics",
"retrieving-mlflow-traces","searching-mlflow-docs"
)
# The Claude Code plugin (installed via a marketplace, separate from the skills
# this script drops directly). Its on-disk state lives across several shared files
# (installed_plugins.json, enabledPlugins in settings.json, known_marketplaces.json,
# the cache dir) shared with the user's OTHER plugins — so we never hand-edit them.
# Detection is read-only; removal is delegated to the official `claude` CLI.
#
# The plugin can be installed from ANY marketplace, so we match by plugin name and
# discover the actual "name@marketplace" key(s) rather than assuming a marketplace.
$script:PluginName = "databricks-ai-dev-kit"
# Read-only detection of the plugin per scope. The scope is recorded by which
# settings.json enables it: user scope in ~/.claude/settings.json, project scope in
# the project's .claude/settings.json(.local). (installed_plugins.json is user-level
# and lists ALL scopes together, so it can't distinguish them.) Returns the enabled
# "name@marketplace" key(s) — any marketplace is matched.
function Get-PluginKeys {
param([string[]]$Files)
$pattern = '"' + [regex]::Escape($script:PluginName) + '@[A-Za-z0-9._-]+"'
$keys = @()
foreach ($f in $Files) {
if (Test-Path $f) {
foreach ($m in [regex]::Matches((Get-Content $f -Raw), $pattern)) { $keys += $m.Value.Trim('"') }
}
}
return @($keys | Sort-Object -Unique)
}
function Get-PluginKeysGlobal { Get-PluginKeys -Files @((Join-Path $env:USERPROFILE ".claude\settings.json")) }
function Get-PluginKeysProject { param([string]$Dir) Get-PluginKeys -Files @((Join-Path $Dir ".claude\settings.json"), (Join-Path $Dir ".claude\settings.local.json")) }
# Count skill folders + 'databricks' MCP entries under the given roots/targets, plus
# hook/state/plugin, returning one " - ..." summary line each. Shared by the project-
# and global-scope summaries below. Read-only.
function Get-LeftoversSummary {
param([string]$Hook, [string]$StateDir, [string]$StateLabel, [string[]]$PluginKeys, [string[]]$SkillRoots, [hashtable[]]$McpTargets)
$lines = @()
$n = 0
foreach ($root in $SkillRoots) {
if (Test-Path $root) { foreach ($name in $script:UninstallSkillNames) { if (Test-Path (Join-Path $root $name)) { $n++ } } }
}
if ($n -gt 0) { $lines += " - $n skill folder(s)" }
$n = 0
foreach ($t in $McpTargets) {
if (-not (Test-Path $t.Path)) { continue }
if ($t.Kind -eq "json" -and (Test-McpJsonHasDatabricks -Path $t.Path -Top $t.Top)) { $n++ }
elseif ($t.Kind -eq "toml" -and (Select-String -Path $t.Path -Pattern 'mcp_servers\.databricks' -Quiet)) { $n++ }
}
if ($n -gt 0) { $lines += " - $n MCP config file(s) with the 'databricks' server" }
if ($Hook -and (Test-Path $Hook) -and (Select-String -Path $Hook -Pattern 'check_update' -Quiet)) { $lines += " - Claude update hook" }
if ($StateDir -and (Test-Path $StateDir)) { $lines += " - $StateLabel" }
if ($PluginKeys.Count -gt 0) { $lines += " - Claude Code plugin: $($PluginKeys -join ' ')" }
return @($lines)
}
# Project-scope artifacts under $Dir (what a project uninstall from that dir removes).
function Get-ProjectLeftoversSummary {
param([string]$Dir)
$skillRoots = @("\.claude\skills","\.cursor\skills","\.github\skills","\.agents\skills","\.gemini\skills","\.windsurf\skills","\.opencode\skills","\.kiro\skills") | ForEach-Object { Join-Path $Dir $_.TrimStart('\') }
$mcpTargets = @(
@{ Path=(Join-Path $Dir ".mcp.json"); Kind="json"; Top="mcpServers" }, @{ Path=(Join-Path $Dir ".cursor\mcp.json"); Kind="json"; Top="mcpServers" }, @{ Path=(Join-Path $Dir ".vscode\mcp.json"); Kind="json"; Top="servers" },
@{ Path=(Join-Path $Dir ".codex\config.toml"); Kind="toml" }, @{ Path=(Join-Path $Dir ".gemini\settings.json"); Kind="json"; Top="mcpServers" },
@{ Path=(Join-Path $Dir "opencode.json"); Kind="json"; Top="mcp" }, @{ Path=(Join-Path $Dir ".kiro\settings\mcp.json"); Kind="json"; Top="mcpServers" }
)
Get-LeftoversSummary -Hook (Join-Path $Dir ".claude\settings.json") -StateDir (Join-Path $Dir ".ai-dev-kit") -StateLabel "state files (.ai-dev-kit/)" `
-PluginKeys (Get-PluginKeysProject -Dir $Dir) -SkillRoots $skillRoots -McpTargets $mcpTargets
}
# Global/user-scope artifacts (what a --global uninstall removes).
function Get-GlobalLeftoversSummary {
$h = $env:USERPROFILE
$installDir = if ($env:AIDEVKIT_HOME) { $env:AIDEVKIT_HOME } else { Join-Path $h ".ai-dev-kit" }
$skillRoots = @(".claude\skills",".cursor\skills",".github\skills",".agents\skills",".gemini\skills",".gemini\antigravity\skills",".codeium\windsurf\skills",".config\opencode\skills",".kiro\skills") | ForEach-Object { Join-Path $h $_ }
$mcpTargets = @(
@{ Path=(Join-Path $h ".claude.json"); Kind="json"; Top="mcpServers" }, @{ Path=(Join-Path $h ".codex\config.toml"); Kind="toml" }, @{ Path=(Join-Path $h ".gemini\settings.json"); Kind="json"; Top="mcpServers" },
@{ Path=(Join-Path $h ".gemini\antigravity\mcp_config.json"); Kind="json"; Top="mcpServers" }, @{ Path=(Join-Path $h ".codeium\windsurf\mcp_config.json"); Kind="json"; Top="mcpServers" },
@{ Path=(Join-Path $h ".config\opencode\opencode.json"); Kind="json"; Top="mcp" }, @{ Path=(Join-Path $h ".kiro\settings\mcp.json"); Kind="json"; Top="mcpServers" }
)
Get-LeftoversSummary -Hook (Join-Path $h ".claude\settings.json") -StateDir $installDir -StateLabel "MCP server runtime / state ($installDir)" `
-PluginKeys (Get-PluginKeysGlobal) -SkillRoots $skillRoots -McpTargets $mcpTargets
}
# Very noticeable end-of-run box warning that files remain in the OTHER scope.
function Show-LeftoversBox {
param([string]$Headline, [string]$Detail, [string[]]$Summary, [string]$Action)
$bar = " ------------------------------------------------------------"
Write-Host ""
Write-Host $bar -ForegroundColor Yellow
Write-Host " $Headline" -ForegroundColor Yellow
Write-Host $bar -ForegroundColor Yellow
Write-Host " $Detail" -ForegroundColor DarkGray
foreach ($l in $Summary) { Write-Host $l }
Write-Host " $Action" -ForegroundColor Yellow
Write-Host $bar -ForegroundColor Yellow
}
function Show-ProjectLeftoversWarning {
param([string]$Dir, [string[]]$Summary)
Show-LeftoversBox -Headline "! PROJECT-LEVEL AI DEV KIT FILES STILL REMAIN" `
-Detail "This global uninstall did not touch project-scoped files in: $Dir" `
-Summary $Summary -Action "Re-run the uninstaller from that folder WITHOUT --global to remove them."
}
function Show-GlobalLeftoversWarning {
param([string[]]$Summary)
Show-LeftoversBox -Headline "! GLOBAL AI DEV KIT FILES STILL REMAIN" `
-Detail "This project uninstall did not touch global (user-level) files:" `
-Summary $Summary -Action "Re-run the uninstaller with --global to remove them."
}
# Remove the plugin from the CURRENT uninstall scope via the official CLI (atomic
# across the shared plugin state - we never hand-edit it). Removes every detected
# "name@marketplace" key (the plugin may come from any marketplace). A project
# install can be 'project' (.claude/settings.json) or 'local' (settings.local.json),
# so a project uninstall tries both CLI scopes. If nothing could be removed this is a
# hard error that reports whether the rest of the uninstall completed and prints the
# exact command to run manually. $OthersRemoved = other artifacts removed this run.
function Remove-ClaudePlugin {
param([int]$OthersRemoved, [string[]]$Keys)
if ($script:Scope -eq "project") { $scopes = @("project","local"); $cmdScope = "project" }
else { $scopes = @("user"); $cmdScope = "user" }
if (Get-Command claude -ErrorAction SilentlyContinue) {
$removed = $false
foreach ($k in $Keys) {
foreach ($sc in $scopes) {
# Subcommand name has varied across versions (uninstall vs remove) — try both.
& claude plugin uninstall $k -y --scope $sc *>$null
if ($LASTEXITCODE -ne 0) { & claude plugin remove $k -y --scope $sc *>$null }
if ($LASTEXITCODE -eq 0) { Write-Msg "removed Claude Code plugin $k ($sc scope)"; $removed = $true }
}
}
if ($removed) { return }
}
$partial = ""; $alt = ""
if ($OthersRemoved -gt 0) { $partial = "Skills, MCP server, and config WERE removed (partial uninstall). " }
if ($script:Scope -eq "project") { $alt = " (or --scope local)" }
$manual = (($Keys | ForEach-Object { "claude plugin uninstall $_ --scope $cmdScope" }) -join "; ")
Write-Err "Could not remove the Claude Code plugin. ${partial}Finish it manually: $manual$alt"
}
# Read-only: true only if the EXACT top-level server key ($Top) contains a
# 'databricks' entry - the same thing removal targets. Does NOT match nested
# occurrences (e.g. ~/.claude.json's projects.<path>.mcpServers.databricks, a
# project-scoped server we never touch) that a plain match would flag.
function Test-McpJsonHasDatabricks {
param([string]$Path, [string]$Top)
if (-not (Test-Path $Path)) { return $false }
try { $cfg = Get-Content $Path -Raw | ConvertFrom-Json } catch { return $false }
return ($cfg.$Top -and $cfg.$Top.PSObject.Properties.Name -contains 'databricks')
}
function Remove-McpJsonKey {
param([string]$Path, [string]$Top)
if (-not (Test-Path $Path)) { return $false }
if (-not (Select-String -Path $Path -Pattern '"databricks"' -Quiet)) { return $false }
if ($script:DryRun) { return $true }
try { $cfg = Get-Content $Path -Raw | ConvertFrom-Json } catch { return $false }
# Only rewrite (and back up) when the exact top-level 'databricks' key is
# present. Otherwise a stray '"databricks"' elsewhere (a foreign server's
# path, a project named 'databricks') would trigger a lossy no-op rewrite —
# and ConvertTo-Json's -Depth would truncate deep configs like ~/.claude.json.
if (-not ($cfg.$Top -and $cfg.$Top.PSObject.Properties.Name -contains 'databricks')) {
return $false
}
Copy-Item $Path "$Path.bak" -Force
$cfg.$Top.PSObject.Properties.Remove('databricks')
if (-not $cfg.$Top.PSObject.Properties.Name) { $cfg.PSObject.Properties.Remove($Top) }
$cfg | ConvertTo-Json -Depth 100 | Set-Content $Path -Encoding UTF8
return $true
}
function Remove-McpTomlBlock {
param([string]$Path)
if (-not (Test-Path $Path)) { return $false }
if (-not (Select-String -Path $Path -Pattern 'mcp_servers\.databricks' -Quiet)) { return $false }
if ($script:DryRun) { return $true }
Copy-Item $Path "$Path.bak" -Force
$out = New-Object System.Collections.Generic.List[string]
$skip = $false
foreach ($line in Get-Content "$Path.bak") {
# Consume the databricks table AND its dotted subtables (e.g. .env);
# any other section header ends the skip.
if ($line -match '^\[mcp_servers\.databricks(\.|\])') { $skip = $true; continue }
if ($line -match '^\[') { $skip = $false }
if (-not $skip) { $out.Add($line) }
}
$out | Set-Content $Path -Encoding UTF8
return $true
}
function Remove-ClaudeHook {
param([string]$Path)
if (-not (Test-Path $Path)) { return $false }
if (-not (Select-String -Path $Path -Pattern 'check_update' -Quiet)) { return $false }
if ($script:DryRun) { return $true }
try { $cfg = Get-Content $Path -Raw | ConvertFrom-Json } catch { return $false }
$ss = $cfg.hooks.SessionStart
if (-not $ss) { return $false } # nothing to change — don't rewrite/back up
foreach ($group in $ss) {
$group.hooks = @($group.hooks | Where-Object { $_.command -notmatch 'check_update' })
}
$cfg.hooks.SessionStart = @($ss | Where-Object { $_.hooks -and $_.hooks.Count -gt 0 })
if (-not $cfg.hooks.SessionStart -or $cfg.hooks.SessionStart.Count -eq 0) {
$cfg.hooks.PSObject.Properties.Remove('SessionStart')
}
Copy-Item $Path "$Path.bak" -Force
$cfg | ConvertTo-Json -Depth 100 | Set-Content $Path -Encoding UTF8
return $true
}
function Invoke-Uninstall {
$home_ = $env:USERPROFILE
if ($script:Scope -eq "global") { $baseDir = $home_ } else { $baseDir = (Get-Location).Path }
$installDir = if ($env:AIDEVKIT_HOME) { $env:AIDEVKIT_HOME }
else { Join-Path $home_ ".ai-dev-kit" }
if ($script:Scope -eq "global") { $stateDir = $installDir } else { $stateDir = Join-Path $baseDir ".ai-dev-kit" }
# Scope strictly gates locations (mirror of install.sh).
if ($script:Scope -eq "global") {
$skillRoots = @(
(Join-Path $home_ ".claude\skills"), (Join-Path $home_ ".cursor\skills"),
(Join-Path $home_ ".github\skills"), (Join-Path $home_ ".agents\skills"),
(Join-Path $home_ ".gemini\skills"), (Join-Path $home_ ".gemini\antigravity\skills"),
(Join-Path $home_ ".codeium\windsurf\skills"), (Join-Path $home_ ".config\opencode\skills"),
(Join-Path $home_ ".kiro\skills")
)
$mcpTargets = @(
@{ Path=(Join-Path $home_ ".claude\mcp.json"); Kind="json"; Top="mcpServers" },
@{ Path=(Join-Path $home_ ".codex\config.toml"); Kind="toml" },
@{ Path=(Join-Path $home_ ".gemini\settings.json"); Kind="json"; Top="mcpServers" },
@{ Path=(Join-Path $home_ ".gemini\antigravity\mcp_config.json"); Kind="json"; Top="mcpServers" },
@{ Path=(Join-Path $home_ ".codeium\windsurf\mcp_config.json"); Kind="json"; Top="mcpServers" },
@{ Path=(Join-Path $home_ ".config\opencode\opencode.json"); Kind="json"; Top="mcp" },
@{ Path=(Join-Path $home_ ".kiro\settings\mcp.json"); Kind="json"; Top="mcpServers" }
)
$hookTargets = @( (Join-Path $home_ ".claude\settings.json") )
} else {
$skillRoots = @(
(Join-Path $baseDir ".claude\skills"), (Join-Path $baseDir ".cursor\skills"),
(Join-Path $baseDir ".github\skills"), (Join-Path $baseDir ".agents\skills"),
(Join-Path $baseDir ".gemini\skills"), (Join-Path $baseDir ".windsurf\skills"),
(Join-Path $baseDir ".opencode\skills"), (Join-Path $baseDir ".kiro\skills")
)
$mcpTargets = @(
@{ Path=(Join-Path $baseDir ".mcp.json"); Kind="json"; Top="mcpServers" },
@{ Path=(Join-Path $baseDir ".cursor\mcp.json"); Kind="json"; Top="mcpServers" },
@{ Path=(Join-Path $baseDir ".vscode\mcp.json"); Kind="json"; Top="servers" },
@{ Path=(Join-Path $baseDir ".codex\config.toml"); Kind="toml" },
@{ Path=(Join-Path $baseDir ".gemini\settings.json"); Kind="json"; Top="mcpServers" },
@{ Path=(Join-Path $baseDir "opencode.json"); Kind="json"; Top="mcp" },
@{ Path=(Join-Path $baseDir ".kiro\settings\mcp.json"); Kind="json"; Top="mcpServers" }
)
$hookTargets = @( (Join-Path $baseDir ".claude\settings.json") )
}
# Build plan
$planSkills = @(); $planMcp = @(); $planHooks = @(); $planRuntime = @(); $planState = @()
foreach ($root in $skillRoots) {
if (-not (Test-Path $root)) { continue }
foreach ($name in $script:UninstallSkillNames) {
$p = Join-Path $root $name
if (Test-Path $p) { $planSkills += $p }
}
}
foreach ($t in $mcpTargets) {
if (-not (Test-Path $t.Path)) { continue }
if ($t.Kind -eq "json" -and (Test-McpJsonHasDatabricks -Path $t.Path -Top $t.Top)) { $planMcp += $t }
elseif ($t.Kind -eq "toml" -and (Select-String -Path $t.Path -Pattern 'mcp_servers\.databricks' -Quiet)) { $planMcp += $t }
}
foreach ($h in $hookTargets) {
if ((Test-Path $h) -and (Select-String -Path $h -Pattern 'check_update' -Quiet)) { $planHooks += $h }
}
if ($script:Scope -eq "global") {
if (Test-Path $installDir) { $planRuntime += $installDir }
}
# On a global uninstall $stateDir IS the runtime dir; when that dir is already in
# $planRuntime the state files inside it are removed along with it - planning them
# separately would make Remove-Item fail on the already-deleted paths.
if ($planRuntime -notcontains $stateDir) {
foreach ($s in @((Join-Path $stateDir ".installed-skills"), (Join-Path $stateDir ".skills-profile"), (Join-Path $stateDir "version"))) {
if (Test-Path $s) { $planState += $s }
}
}
$projMarker = Join-Path $baseDir ".ai-dev-kit"
if ($script:Scope -eq "project" -and (Test-Path $projMarker)) { $planState += $projMarker }
# Claude Code plugin at the CURRENT scope — collect the enabled "name@marketplace"
# key(s) so any marketplace is matched; these are what we remove.
if ($script:Scope -eq "global") { $pluginKeys = Get-PluginKeysGlobal } else { $pluginKeys = Get-PluginKeysProject -Dir $baseDir }
$planPlugin = ($pluginKeys.Count -gt 0)
# Warn about artifacts left behind in the OTHER scope. A global uninstall looks
# for project-scope files in the current folder; a project uninstall looks for
# global/user-level files. Skip the $cwd scan when it is $HOME (there project and
# global paths coincide and are already handled by the global side).
$projectLeftovers = @(); $globalLeftovers = @()
$cwd = (Get-Location).Path
if ($script:Scope -eq "global") {
if ($cwd -ne $env:USERPROFILE) { $projectLeftovers = Get-ProjectLeftoversSummary -Dir $cwd }
} else {
if ($baseDir -ne $env:USERPROFILE) { $globalLeftovers = Get-GlobalLeftoversSummary }
}
$total = $planSkills.Count + $planMcp.Count + $planHooks.Count + $planRuntime.Count + $planState.Count + $pluginKeys.Count
if ($total -eq 0) {
Write-Ok "Nothing to uninstall for $($script:Scope) scope at $baseDir - no AI Dev Kit artifacts found."
if ($script:Scope -eq "project" -and -not $globalLeftovers.Count) { Write-Msg "Tip: pass --global to remove a global install." }
if ($projectLeftovers.Count) { Show-ProjectLeftoversWarning -Dir $cwd -Summary $projectLeftovers }
if ($globalLeftovers.Count) { Show-GlobalLeftoversWarning -Summary $globalLeftovers }
return
}
Write-Step "Uninstall plan ($($script:Scope) scope)"
if ($planSkills.Count) { Write-Host " Skill folders ($($planSkills.Count)):" -ForegroundColor White; $planSkills | ForEach-Object { Write-Host " $_" } }
if ($planMcp.Count) { Write-Host " MCP config - remove 'databricks' entry ($($planMcp.Count)):" -ForegroundColor White; $planMcp | ForEach-Object { Write-Host " $($_.Path)" } }
if ($planHooks.Count) { Write-Host " Claude update hook ($($planHooks.Count)):" -ForegroundColor White; $planHooks | ForEach-Object { Write-Host " $_" } }
if ($planRuntime.Count){ Write-Host " MCP server runtime:" -ForegroundColor White; $planRuntime | ForEach-Object { Write-Host " $_" } }
if ($planState.Count) { Write-Host " State files:" -ForegroundColor White; $planState | ForEach-Object { Write-Host " $_" } }
if ($planPlugin) {
Write-Host " Claude Code plugin:" -ForegroundColor White
foreach ($k in $pluginKeys) { Write-Host " $k (removed via the claude CLI, $($script:Scope) scope)" -ForegroundColor DarkGray }
Write-Host " ! Heads up: the AI Dev Kit Claude Code plugin will also be removed." -ForegroundColor Yellow
}
Write-Host ""
Write-Msg "Config files are backed up to <file>.bak before editing."
if ($script:DryRun) {
if ($projectLeftovers.Count) { Show-ProjectLeftoversWarning -Dir $cwd -Summary $projectLeftovers }
if ($globalLeftovers.Count) { Show-GlobalLeftoversWarning -Summary $globalLeftovers }
Write-Ok "Dry run - nothing was changed. Re-run without --dry-run to apply."
return
}
if (-not $script:AssumeYes) {
$reply = Read-Host " Remove these $total item(s)? [y/N]"
if ($reply -notmatch '^(y|yes)$') { Write-Warn "Aborted - nothing removed."; return }
}
Write-Step "Removing"
foreach ($p in $planSkills) { Remove-Item -Recurse -Force $p; Write-Msg "removed $p" }
foreach ($t in $planMcp) {
if ($t.Kind -eq "json") { if (Remove-McpJsonKey -Path $t.Path -Top $t.Top) { Write-Msg "cleaned $($t.Path)" } }
else { if (Remove-McpTomlBlock -Path $t.Path) { Write-Msg "cleaned $($t.Path)" } }
}
foreach ($p in $planHooks) { if (Remove-ClaudeHook -Path $p) { Write-Msg "cleaned hook in $p" } }
foreach ($p in $planRuntime) { Remove-Item -Recurse -Force $p; Write-Msg "removed $p" }
foreach ($p in $planState) { Remove-Item -Recurse -Force $p; Write-Msg "removed $p" }
if ($planPlugin) { Remove-ClaudePlugin -OthersRemoved ($total - $pluginKeys.Count) -Keys $pluginKeys }
Write-Host ""
Write-Ok "AI Dev Kit uninstalled ($($script:Scope) scope)."
Write-Msg "Other scopes and per-editor .bak backups were left untouched."
if ($projectLeftovers.Count) { Show-ProjectLeftoversWarning -Dir $cwd -Summary $projectLeftovers }
if ($globalLeftovers.Count) { Show-GlobalLeftoversWarning -Summary $globalLeftovers }
}
if ($script:Uninstall) { Invoke-Uninstall; return }
# ─── 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; Locked }
)
$count = $Items.Count
$cursor = 0
$states = @()
$locked = @()
foreach ($item in $Items) {
if ($item.Locked) {
$locked += $true
$states += $true # locked items are always selected
} else {
$locked += $false
$states += [bool]$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 }
}
}
# Locked items are always selected
for ($j = 0; $j -lt $count; $j++) { if ($locked[$j]) { $states[$j] = $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++) {
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
# Truncate the hint so the line can't wrap past the window width
# (a wrapped line would desync the cursor-relative redraw).
$hint = $Items[$j].Hint
$avail = [Console]::WindowWidth - [Console]::CursorLeft - 1
if ($avail -lt 0) { $avail = 0 }
if ($hint.Length -gt $avail) { $hint = $hint.Substring(0, $avail) }
if ($states[$j]) {
Write-Host $hint -ForegroundColor Green -NoNewline
} else {
Write-Host $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 -and -not $locked[$cursor]) {
$states[$cursor] = -not $states[$cursor]
}
}
13 { # Enter
if ($cursor -lt $count) {
if (-not $locked[$cursor]) { $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 {}