-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInstall-ClaudeCode.ps1
More file actions
763 lines (636 loc) · 25.2 KB
/
Copy pathInstall-ClaudeCode.ps1
File metadata and controls
763 lines (636 loc) · 25.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
#Requires -RunAsAdministrator
<#
.SYNOPSIS
Claude Code Installer for Windows
.DESCRIPTION
Automated installer for Claude Code CLI and VSCode extension with all prerequisites
#>
[CmdletBinding()]
param(
[switch]$Silent,
[switch]$InstallCLI,
[switch]$InstallVSCode,
[switch]$InstallExtension,
[switch]$SkipGit
)
# Configuration
$Script:Config = @{
GitInstallerUrl = "https://github.com/git-for-windows/git/releases/download/v2.52.0.windows.1/Git-2.52.0-64-bit.exe"
VSCodeInstallerUrl = "https://code.visualstudio.com/sha/download?build=stable&os=win32-x64-user"
#NodeInstallerUrl = "https://nodejs.org/dist/v22.12.0/node-v22.12.0-x64.msi"
NodeInstallerUrl = "https://nodejs.org/dist/latest/node-v25.3.0-x64.msi"
ClaudeInstallScript = "https://claude.ai/install.ps1"
ClaudeExtensionId = "Anthropic.claude-code"
LocalBinPath = "$env:USERPROFILE\.local\bin"
TempDir = "$env:TEMP\ClaudeCodeInstaller"
LogFile = "$env:TEMP\ClaudeCodeInstaller.log"
}
# Color scheme for console output
$Script:Colors = @{
Success = "Green"
Error = "Red"
Warning = "Yellow"
Info = "Cyan"
Prompt = "White"
}
#region Logging Functions
function Write-Log {
param(
[string]$Message,
[ValidateSet("Info", "Success", "Warning", "Error")]
[string]$Level = "Info"
)
$timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
$logMessage = "[$timestamp] [$Level] $Message"
Add-Content -Path $Script:Config.LogFile -Value $logMessage
$color = $Script:Colors[$Level]
Write-Host $Message -ForegroundColor $color
}
#endregion
#region UI Functions
function Show-Banner {
$host.UI.RawUI.WindowTitle = "Claude Code Installer"
Clear-Host
Write-Host @"
╔════════════════════════════════════════════════════════════╗
║ ║
║ Claude Code Installer for Windows ║
║ Made by InterWorks :) ║
║ ║
╚════════════════════════════════════════════════════════════╝
"@ -ForegroundColor Cyan
Write-Host ""
}
function Show-Menu {
Write-Host "Please select installation options:" -ForegroundColor $Script:Colors.Prompt
Write-Host ""
Write-Host " [1] Install Claude Code CLI" -ForegroundColor White
Write-Host " [2] Install VSCode + Claude Code Extension" -ForegroundColor White
Write-Host " [3] Install Both (CLI + VSCode Extension)" -ForegroundColor White
Write-Host " [4] Exit" -ForegroundColor White
Write-Host ""
do {
$choice = Read-Host "Enter your choice (1-4)"
} while ($choice -notmatch '^[1-4]$')
return $choice
}
#endregion
#region Prerequisite Checks
function Test-Administrator {
$currentUser = [Security.Principal.WindowsIdentity]::GetCurrent()
$principal = New-Object Security.Principal.WindowsPrincipal($currentUser)
return $principal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
}
function Test-GitInstalled {
try {
$gitVersion = git --version 2>$null
if ($gitVersion) {
Write-Log "Git is already installed: $gitVersion" -Level Success
return $true
}
}
catch {
Write-Log "Git is not installed" -Level Warning
return $false
}
return $false
}
function Test-GitBashPath {
$gitBashPath = "C:\Program Files\Git\bin\bash.exe"
if (Test-Path $gitBashPath) {
return $gitBashPath
}
# Check alternative locations
$altPaths = @(
"C:\Program Files (x86)\Git\bin\bash.exe",
"$env:ProgramFiles\Git\bin\bash.exe",
"${env:ProgramFiles(x86)}\Git\bin\bash.exe"
)
foreach ($path in $altPaths) {
if (Test-Path $path) {
return $path
}
}
return $null
}
function Test-NodeInstalled {
try {
$nodeVersion = node --version 2>$null
if ($nodeVersion) {
Write-Log "Node.js is already installed: $nodeVersion" -Level Success
return $true
}
}
catch {
Write-Log "Node.js is not installed" -Level Warning
return $false
}
return $false
}
function Test-VSCodeInstalled {
$vscodePaths = @(
"$env:LOCALAPPDATA\Programs\Microsoft VS Code\Code.exe",
"$env:ProgramFiles\Microsoft VS Code\Code.exe",
"${env:ProgramFiles(x86)}\Microsoft VS Code\Code.exe"
)
foreach ($path in $vscodePaths) {
if (Test-Path $path) {
Write-Log "VSCode is already installed at: $path" -Level Success
return $true
}
}
Write-Log "VSCode is not installed" -Level Warning
return $false
}
function Test-ClaudeCLIInstalled {
try {
$claudeVersion = claude --version 2>$null
if ($claudeVersion) {
return $true
}
}
catch {
return $false
}
return $false
}
function Test-ClaudeExtensionInstalled {
try {
$extensions = code --list-extensions 2>$null
if ($extensions -contains $Script:Config.ClaudeExtensionId) {
return $true
}
}
catch {
Write-Log "Could not check for Claude Code extension" -Level Warning
return $false
}
return $false
}
function Test-PathVariable {
param([string]$PathToCheck)
$userPath = [Environment]::GetEnvironmentVariable("Path", "User")
$machinePath = [Environment]::GetEnvironmentVariable("Path", "Machine")
$fullPath = "$userPath;$machinePath"
return $fullPath -split ';' | Where-Object { $_ -eq $PathToCheck }
}
#endregion
#region Installation Functions
function Install-GitForWindows {
Write-Log "Downloading Git for Windows..." -Level Info
$installerPath = Join-Path $Script:Config.TempDir "git-installer.exe"
try {
# Download Git installer
$ProgressPreference = 'SilentlyContinue'
Invoke-WebRequest -Uri $Script:Config.GitInstallerUrl -OutFile $installerPath -UseBasicParsing
$ProgressPreference = 'Continue'
Write-Log "Installing Git for Windows (this may take a few minutes)..." -Level Info
# Install Git silently
$process = Start-Process -FilePath $installerPath -ArgumentList "/VERYSILENT", "/NORESTART", "/NOCANCEL", "/SP-", "/CLOSEAPPLICATIONS", "/RESTARTAPPLICATIONS", "/COMPONENTS=gitlfs" -Wait -PassThru
if ($process.ExitCode -eq 0) {
Write-Log "Git for Windows installed successfully" -Level Success
# Refresh environment variables
$env:Path = [System.Environment]::GetEnvironmentVariable("Path", "Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path", "User")
return $true
}
else {
Write-Log "Git installation failed with exit code: $($process.ExitCode)" -Level Error
return $false
}
}
catch {
Write-Log "Error installing Git: $_" -Level Error
return $false
}
}
function Set-GitBashEnvironmentVariable {
# Check if already set
$existingPath = [Environment]::GetEnvironmentVariable("CLAUDE_CODE_GIT_BASH_PATH", "User")
if ($existingPath -and (Test-Path $existingPath)) {
Write-Log "CLAUDE_CODE_GIT_BASH_PATH is already set to: $existingPath" -Level Success
return $true
}
$gitBashPath = Test-GitBashPath
if (-not $gitBashPath) {
Write-Log "Could not find Git Bash executable" -Level Error
return $false
}
Write-Log "Setting CLAUDE_CODE_GIT_BASH_PATH environment variable..." -Level Info
try {
[Environment]::SetEnvironmentVariable("CLAUDE_CODE_GIT_BASH_PATH", $gitBashPath, "User")
$env:CLAUDE_CODE_GIT_BASH_PATH = $gitBashPath
Write-Log "Git Bash path set to: $gitBashPath" -Level Success
return $true
}
catch {
Write-Log "Error setting Git Bash path: $_" -Level Error
return $false
}
}
function Install-NodeJS {
Write-Log "Downloading Node.js installer..." -Level Info
$installerPath = Join-Path $Script:Config.TempDir "node-installer.msi"
try {
# Download Node.js installer
$ProgressPreference = 'SilentlyContinue'
Invoke-WebRequest -Uri $Script:Config.NodeInstallerUrl -OutFile $installerPath -UseBasicParsing
$ProgressPreference = 'Continue'
Write-Log "Installing Node.js (this may take a few minutes)..." -Level Info
# Install Node.js silently
$process = Start-Process -FilePath "msiexec.exe" -ArgumentList "/i", "`"$installerPath`"", "/quiet", "/norestart" -Wait -PassThru
if ($process.ExitCode -eq 0) {
Write-Log "Node.js installed successfully" -Level Success
# Refresh environment variables
$env:Path = [System.Environment]::GetEnvironmentVariable("Path", "Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path", "User")
return $true
}
else {
Write-Log "Node.js installation failed with exit code: $($process.ExitCode)" -Level Error
return $false
}
}
catch {
Write-Log "Error installing Node.js: $_" -Level Error
return $false
}
}
function Add-LocalBinToPath {
$localBinPath = $Script:Config.LocalBinPath
# Create directory if it doesn't exist
if (-not (Test-Path $localBinPath)) {
Write-Log "Creating directory: $localBinPath" -Level Info
New-Item -Path $localBinPath -ItemType Directory -Force | Out-Null
}
# Check if already in PATH
if (Test-PathVariable -PathToCheck $localBinPath) {
Write-Log "Local bin directory is already in PATH" -Level Success
return $true
}
Write-Log "Adding $localBinPath to user PATH..." -Level Info
try {
$currentPath = [Environment]::GetEnvironmentVariable("Path", "User")
$newPath = "$currentPath;$localBinPath"
[Environment]::SetEnvironmentVariable("Path", $newPath, "User")
# Update current session
$env:Path += ";$localBinPath"
Write-Log "Local bin directory added to PATH" -Level Success
return $true
}
catch {
Write-Log "Error adding to PATH: $_" -Level Error
return $false
}
}
function Install-ClaudeCLI {
Write-Log "Installing Claude Code CLI..." -Level Info
try {
# Download the native installer script
Write-Log "Downloading Claude Code installer..." -Level Info
$installerScript = Join-Path $Script:Config.TempDir "claude-install.ps1"
$ProgressPreference = 'SilentlyContinue'
Invoke-WebRequest -Uri $Script:Config.ClaudeInstallScript -OutFile $installerScript -UseBasicParsing
$ProgressPreference = 'Continue'
Write-Log "Running Claude Code installer (this may take a few minutes)..." -Level Info
# Run the installer script
$process = Start-Process -FilePath "powershell.exe" -ArgumentList "-ExecutionPolicy", "Bypass", "-File", "`"$installerScript`"" -Wait -PassThru -NoNewWindow
if ($process.ExitCode -eq 0) {
Write-Log "Claude Code CLI installed successfully" -Level Success
# Refresh environment variables
$env:Path = [System.Environment]::GetEnvironmentVariable("Path", "Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path", "User")
return $true
}
else {
Write-Log "Claude Code CLI installation failed with exit code: $($process.ExitCode)" -Level Error
return $false
}
}
catch {
Write-Log "Error installing Claude Code CLI: $_" -Level Error
return $false
}
}
function New-VSCodeDesktopShortcut {
Write-Log "Creating Desktop shortcut for VSCode..." -Level Info
$vscodePaths = @(
"$env:LOCALAPPDATA\Programs\Microsoft VS Code\Code.exe",
"$env:ProgramFiles\Microsoft VS Code\Code.exe",
"${env:ProgramFiles(x86)}\Microsoft VS Code\Code.exe"
)
$vscodeExePath = $null
foreach ($path in $vscodePaths) {
if (Test-Path $path) {
$vscodeExePath = $path
break
}
}
if (-not $vscodeExePath) {
Write-Log "Could not find VSCode executable for shortcut creation" -Level Warning
return $false
}
try {
$desktopPath = [Environment]::GetFolderPath("Desktop")
$shortcutPath = Join-Path $desktopPath "Visual Studio Code.lnk"
$wshShell = New-Object -ComObject WScript.Shell
$shortcut = $wshShell.CreateShortcut($shortcutPath)
$shortcut.TargetPath = $vscodeExePath
$shortcut.WorkingDirectory = [Environment]::GetFolderPath("UserProfile")
$shortcut.Description = "Visual Studio Code"
$shortcut.Save()
Write-Log "Desktop shortcut created successfully" -Level Success
return $true
}
catch {
Write-Log "Error creating desktop shortcut: $_" -Level Warning
return $false
}
}
function Install-VSCode {
Write-Log "Downloading Visual Studio Code..." -Level Info
$installerPath = Join-Path $Script:Config.TempDir "vscode-installer.exe"
try {
# Download VSCode installer
$ProgressPreference = 'SilentlyContinue'
Invoke-WebRequest -Uri $Script:Config.VSCodeInstallerUrl -OutFile $installerPath -UseBasicParsing
$ProgressPreference = 'Continue'
Write-Log "Installing Visual Studio Code..." -Level Info
# Install VSCode silently
$process = Start-Process -FilePath $installerPath -ArgumentList "/VERYSILENT", "/NORESTART", "/MERGETASKS=!runcode,addcontextmenufiles,addcontextmenufolders,addtopath" -Wait -PassThru
if ($process.ExitCode -eq 0) {
Write-Log "Visual Studio Code installed successfully" -Level Success
# Refresh environment variables
$env:Path = [System.Environment]::GetEnvironmentVariable("Path", "Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path", "User")
# Create desktop shortcut
New-VSCodeDesktopShortcut
return $true
}
else {
Write-Log "VSCode installation failed with exit code: $($process.ExitCode)" -Level Error
return $false
}
}
catch {
Write-Log "Error installing VSCode: $_" -Level Error
return $false
}
}
function Install-DevSetupSkill {
$skillDir = Join-Path $env:USERPROFILE ".claude\skills\dev-setup"
$skillFile = Join-Path $skillDir "SKILL.md"
Write-Log "Installing InterWorks developer-setup skill..." -Level Info
try {
if (-not (Test-Path $skillDir)) {
New-Item -Path $skillDir -ItemType Directory -Force | Out-Null
}
# SKILL_CONTENT_START - replaced at build time by the workflow from SKILL.md
$skillContent = @'
##SKILL_CONTENT##
'@
# SKILL_CONTENT_END
# Fallback for local/dev runs where the placeholder was not replaced by CI
if ($skillContent.Trim() -eq '##SKILL_CONTENT##') {
$scriptRoot = $PSScriptRoot
if (-not $scriptRoot -and $MyInvocation.MyCommand.Path) {
$scriptRoot = Split-Path -Path $MyInvocation.MyCommand.Path -Parent
}
$sourceSkillFile = if ($scriptRoot) { Join-Path $scriptRoot "SKILL.md" } else { $null }
if ($sourceSkillFile -and (Test-Path -Path $sourceSkillFile)) {
Write-Log "Loading SKILL.md from disk (local/dev run)" -Level Info
$skillContent = Get-Content -Path $sourceSkillFile -Raw
}
else {
Write-Log "Skill content placeholder not replaced and no local SKILL.md found — skipping skill install" -Level Warning
return $false
}
}
if (Test-Path -Path $skillFile) {
$existingContent = Get-Content -Path $skillFile -Raw
if ($existingContent -eq $skillContent) {
Write-Log "Developer-setup skill is already up to date: $skillFile" -Level Success
return $true
}
$backupFile = Join-Path (Split-Path -Path $skillFile -Parent) ("{0}.{1}.bak" -f (Split-Path -Path $skillFile -Leaf), (Get-Date -Format "yyyyMMddHHmmss"))
Copy-Item -Path $skillFile -Destination $backupFile
Write-Log "Existing developer-setup skill backed up to: $backupFile" -Level Info
}
Set-Content -Path $skillFile -Value $skillContent -Encoding UTF8
Write-Log "Developer-setup skill installed to: $skillFile" -Level Success
return $true
}
catch {
Write-Log "Error installing developer-setup skill: $_" -Level Error
return $false
}
}
function Install-ClaudeExtension {
Write-Log "Installing Claude Code extension for VSCode..." -Level Info
try {
# Install extension using code CLI
$process = Start-Process -FilePath "code" -ArgumentList "--install-extension", $Script:Config.ClaudeExtensionId, "--force" -Wait -PassThru -NoNewWindow
if ($process.ExitCode -eq 0) {
Write-Log "Claude Code extension installed successfully" -Level Success
return $true
}
else {
Write-Log "Extension installation failed with exit code: $($process.ExitCode)" -Level Error
return $false
}
}
catch {
Write-Log "Error installing extension: $_" -Level Error
return $false
}
}
#endregion
#region Main Installation Process
function Start-Installation {
param(
[bool]$InstallCLI,
[bool]$InstallVSCodeAndExtension
)
Write-Log "Starting Claude Code installation process..." -Level Info
Write-Host ""
# Step 1: Install Git if needed
if (-not (Test-GitInstalled)) {
Write-Log "Git for Windows is required to install Claude Code CLI" -Level Warning
if (-not $Silent) {
$response = Read-Host "Install Git for Windows? (Y/N)"
if ($response -ne 'Y' -and $response -ne 'y') {
Write-Log "Installation cancelled by user" -Level Warning
return $false
}
}
if (-not (Install-GitForWindows)) {
Write-Log "Git installation failed. Cannot continue." -Level Error
return $false
}
}
# Step 2: Configure Git Bash path
if (-not (Set-GitBashEnvironmentVariable)) {
Write-Log "Failed to configure Git Bash path" -Level Error
}
# Step 3: Add local bin to PATH
if (-not (Add-LocalBinToPath)) {
Write-Log "Failed to add local bin to PATH" -Level Error
}
# Step 4: Install Node.js if needed
if (-not (Test-NodeInstalled)) {
if (-not (Install-NodeJS)) {
Write-Log "Node.js installation failed" -Level Warning
}
}
# Step 6: Install Claude CLI if requested
if ($InstallCLI) {
Write-Host ""
$cliInstalled = Test-ClaudeCLIInstalled
if ($cliInstalled) {
Write-Log "Claude Code CLI is already working properly, skipping installation" -Level Success
}
else {
if (-not (Install-ClaudeCLI)) {
Write-Log "Claude CLI installation failed" -Level Error
return $false
}
}
}
# Step 7: Install developer-setup skill
if (-not (Install-DevSetupSkill)) {
Write-Log "Developer-setup skill installation failed" -Level Warning
}
# Step 8: Install VSCode and extension if requested
if ($InstallVSCodeAndExtension) {
Write-Host ""
$vscodeInstalled = Test-VSCodeInstalled
if (-not $vscodeInstalled) {
if (-not $Silent) {
$response = Read-Host "Install Visual Studio Code? (Y/N)"
if ($response -eq 'Y' -or $response -eq 'y') {
if (-not (Install-VSCode)) {
Write-Log "VSCode installation failed" -Level Error
return $false
}
}
else {
Write-Log "Skipping VSCode installation" -Level Warning
return $false
}
}
else {
if (-not (Install-VSCode)) {
Write-Log "VSCode installation failed" -Level Error
return $false
}
}
}
# Install extension
Write-Host ""
$extensionInstalled = Test-ClaudeExtensionInstalled
if ($extensionInstalled -eq $true) {
Write-Log "Claude Code extension is already installed, skipping installation" -Level Success
}
else {
if (-not (Install-ClaudeExtension)) {
Write-Log "Extension installation failed" -Level Error
}
}
}
return $true
}
function Show-CompletionMessage {
param(
[bool]$InstalledCLI,
[bool]$InstalledVSCode
)
$host.UI.RawUI.WindowTitle = "Claude Code Installer"
Write-Host ""
Write-Host "═══════════════════════════════════════════════════════════" -ForegroundColor Green
Write-Host " Installation Complete!" -ForegroundColor Green
Write-Host "═══════════════════════════════════════════════════════════" -ForegroundColor Green
Write-Host ""
Write-Log "Claude Code has been installed successfully" -Level Success
Write-Host ""
Write-Host "IMPORTANT: " -ForegroundColor Yellow -NoNewline
Write-Host "Please restart your terminal/VSCode for changes to take effect" -ForegroundColor White
Write-Host ""
if ($InstalledCLI) {
Write-Host "To use Claude Code CLI, open a new PowerShell or CMD window and run:" -ForegroundColor White
Write-Host " claude" -ForegroundColor Cyan
Write-Host ""
Write-Host "You will be prompted to log in to your Anthropic account on first run." -ForegroundColor White
Write-Host ""
}
if ($InstalledVSCode) {
Write-Host "The Claude Code extension is available in VSCode." -ForegroundColor White
Write-Host "You will be prompted to log in to your Anthropic account the first time you use it." -ForegroundColor White
Write-Host ""
}
Write-Host "Next step: " -ForegroundColor Yellow -NoNewline
Write-Host "Open Claude Code and run " -ForegroundColor White -NoNewline
Write-Host "/dev-setup" -ForegroundColor Cyan -NoNewline
Write-Host " to complete your environment setup (GitHub, Python, and more)." -ForegroundColor White
Write-Host ""
Write-Host "Installation log saved to: $($Script:Config.LogFile)" -ForegroundColor Gray
Write-Host ""
}
#endregion
#region Main Entry Point
function Main {
# Initialize
if (-not (Test-Path $Script:Config.TempDir)) {
New-Item -Path $Script:Config.TempDir -ItemType Directory -Force | Out-Null
}
# Check for admin rights
if (-not (Test-Administrator)) {
Write-Host "This installer requires administrator privileges." -ForegroundColor Red
Write-Host "Please run as administrator (Right-click -> Run as Administrator)" -ForegroundColor Yellow
Read-Host "Press Enter to exit"
exit 1
}
Show-Banner
# Determine installation mode
if ($Silent) {
# -InstallVSCode and -InstallExtension both trigger the combined VSCode + extension path
$installVSCodeAndExtension = $InstallVSCode -or $InstallExtension
$success = Start-Installation -InstallCLI:$InstallCLI -InstallVSCodeAndExtension:$installVSCodeAndExtension
if ($success) {
Show-CompletionMessage -InstalledCLI:$InstallCLI -InstalledVSCode:$installVSCodeAndExtension
}
else {
Write-Log "Installation did not complete successfully. Check the log for details: $($Script:Config.LogFile)" -Level Error
exit 1
}
}
else {
# Interactive mode
$choice = Show-Menu
switch ($choice) {
"1" {
if (Start-Installation -InstallCLI $true -InstallVSCodeAndExtension $false) {
Show-CompletionMessage -InstalledCLI $true -InstalledVSCode $false
}
}
"2" {
if (Start-Installation -InstallCLI $false -InstallVSCodeAndExtension $true) {
Show-CompletionMessage -InstalledCLI $false -InstalledVSCode $true
}
}
"3" {
if (Start-Installation -InstallCLI $true -InstallVSCodeAndExtension $true) {
Show-CompletionMessage -InstalledCLI $true -InstalledVSCode $true
}
}
"4" {
Write-Log "Installation cancelled by user" -Level Warning
exit 0
}
}
}
# Cleanup
if (Test-Path $Script:Config.TempDir) {
Remove-Item -Path $Script:Config.TempDir -Recurse -Force -ErrorAction SilentlyContinue
}
Write-Host ""
Read-Host "Press Enter to exit"
}
# Run the installer
Main
#endregion