-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathinstall.ps1
More file actions
1807 lines (1627 loc) · 74.1 KB
/
install.ps1
File metadata and controls
1807 lines (1627 loc) · 74.1 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
# A11y Agent Team Installer (Windows PowerShell)
# Built by Community Access - https://community-access.org
#
# NOTE: Keep this file ASCII-only. Windows PowerShell 5.1 reads .ps1 files
# as Windows-1252 when no UTF-8 BOM is present, which corrupts non-ASCII
# characters (e.g. em-dashes become right double-quotes, breaking strings).
#
# One-liner:
# irm https://raw.githubusercontent.com/Community-Access/accessibility-agents/main/install.ps1 | iex
param(
[switch]$Project,
[switch]$Global,
[switch]$Copilot,
[switch]$Cli,
[switch]$Codex,
[switch]$Gemini,
[switch]$Yes,
[switch]$NoAutoUpdate,
[switch]$Check,
[switch]$DryRun,
[switch]$VsCodeStable,
[switch]$VsCodeInsiders,
[switch]$VsCodeBoth,
[switch]$McpProfileStable,
[switch]$McpProfileInsiders,
[switch]$McpProfileBoth,
[Alias('summary')]
[string]$SummaryPath
)
$ErrorActionPreference = "Stop"
$AutoApprove = $Yes.IsPresent
$OptionalPlatformFlags = $Copilot.IsPresent -or $Cli.IsPresent -or $Codex.IsPresent -or $Gemini.IsPresent
$ScriptDirForHelpers = if ($MyInvocation.MyCommand.Path) { Split-Path -Parent $MyInvocation.MyCommand.Path } else { (Get-Location).Path }
. (Join-Path $ScriptDirForHelpers 'scripts\Installer.Common.ps1')
# Determine source: running from repo clone or downloaded?
$Downloaded = $false
$ScriptDir = if ($MyInvocation.MyCommand.Path) {
Split-Path -Parent $MyInvocation.MyCommand.Path
}
else {
$null
}
if (-not $ScriptDir -or -not (Test-Path (Join-Path $ScriptDir ".claude\agents"))) {
# Running from irm pipe or without repo - download first
$Downloaded = $true
$TmpDir = Join-Path $env:TEMP "a11y-agent-team-install-$(Get-Random)"
Write-Host ""
Write-Host " Downloading A11y Agent Team..."
if (-not (Get-Command git -ErrorAction SilentlyContinue)) {
Write-Host " Error: git is required. Install git and try again."
exit 1
}
git clone --quiet https://github.com/Community-Access/accessibility-agents.git $TmpDir 2>&1 | Out-Null
if ($LASTEXITCODE -ne 0) {
Write-Host " Error: git clone failed. Check your network connection and try again."
exit 1
}
$ScriptDir = $TmpDir
Write-Host " Downloaded."
}
$AgentsSrc = Join-Path $ScriptDir ".claude\agents"
$CopilotAgentsSrc = Join-Path $ScriptDir ".github\agents"
$CopilotConfigSrc = Join-Path $ScriptDir ".github"
$McpServerSrc = Join-Path $ScriptDir "mcp-server"
$CodexConfigSrc = Join-Path $ScriptDir ".codex\config.toml"
$CodexRolesSrc = Join-Path $ScriptDir ".codex\roles"
$CodexSkillsSrc = Join-Path $ScriptDir "codex-skills"
# Auto-detect agents from source directory
$Agents = @()
if (Test-Path $AgentsSrc) {
$Agents = Get-ChildItem -Path $AgentsSrc -Filter "*.md" | Select-Object -ExpandProperty Name
}
if ($Agents.Count -eq 0) {
Write-Host " Error: No agents found in $AgentsSrc"
Write-Host " Make sure you are running this script from the a11y-agent-team directory."
if ($Downloaded) { Remove-Item -Recurse -Force $TmpDir -ErrorAction SilentlyContinue }
exit 1
}
Write-Host ""
Write-Host " A11y Agent Team Installer"
Write-Host " Built by Community Access"
Write-Host " ========================="
Write-Host ""
Write-Host " Where would you like to install?"
Write-Host ""
Write-Host " 1) Project - Install to .claude\ in the current directory"
Write-Host " (recommended, check into version control)"
Write-Host ""
Write-Host " 2) Global - Install to ~\.claude\"
Write-Host " (available in all your projects)"
Write-Host ""
if ($Project -and $Global) {
Write-Host " Error: Choose either -Project or -Global, not both."
exit 1
}
$Choice = if ($Project) {
'1'
}
elseif ($Global) {
'2'
}
else {
if (-not (Test-InteractivePrompting)) {
throw "Choose either -Project or -Global when running non-interactively."
}
Read-Host " Choose [1/2]"
}
switch ($Choice) {
"1" {
$TargetDir = Join-Path (Get-Location) ".claude"
Write-Host ""
Write-Host " Installing to project: $(Get-Location)"
}
"2" {
$TargetDir = Join-Path $env:USERPROFILE ".claude"
Write-Host ""
Write-Host " Installing globally to: $TargetDir"
}
default {
Write-Host " Invalid choice. Exiting."
exit 1
}
}
# ---------------------------------------------------------------------------
# Merge-ConfigFile: append/update our section in a config markdown file.
# Never overwrites existing user content. Uses <!-- a11y-agent-team --> markers
# so the user's own content above/below our section is always preserved.
# ---------------------------------------------------------------------------
function Merge-ConfigFile {
param([string]$SrcFile, [string]$DstFile, [string]$Label)
$start = "<!-- a11y-agent-team: start -->"
$end = "<!-- a11y-agent-team: end -->"
$body = ([IO.File]::ReadAllText($SrcFile, [Text.Encoding]::UTF8)).TrimEnd()
$block = "$start`n$body`n$end"
if (-not (Test-Path $DstFile)) {
[IO.File]::WriteAllText($DstFile, "$block`n", [Text.Encoding]::UTF8)
Write-Host " + $Label (created)"
return
}
$existing = [IO.File]::ReadAllText($DstFile, [Text.Encoding]::UTF8)
if ($existing -match [regex]::Escape($start)) {
$pattern = "(?s)" + [regex]::Escape($start) + ".*?" + [regex]::Escape($end)
$updated = [regex]::Replace($existing, $pattern, $block)
[IO.File]::WriteAllText($DstFile, $updated, [Text.Encoding]::UTF8)
Write-Host " ~ $Label (updated our existing section)"
}
else {
[IO.File]::WriteAllText($DstFile, $existing.TrimEnd() + "`n`n$block`n", [Text.Encoding]::UTF8)
Write-Host " + $Label (merged into your existing file)"
}
}
function Write-InstallSummaryFile {
param(
[string]$Path,
[hashtable]$Data
)
Write-A11ySummaryFile -Path $Path -Data $Data
}
function Configure-VSCodeMcpSettings {
param([string]$SettingsPath, [string]$Url)
$SettingsDir = Split-Path -Parent $SettingsPath
if (-not (Test-Path $SettingsDir)) {
New-Item -ItemType Directory -Force -Path $SettingsDir | Out-Null
}
$SettingsObject = [PSCustomObject]@{}
if (Test-Path $SettingsPath) {
try {
$Raw = Get-Content $SettingsPath -Raw
if (-not [string]::IsNullOrWhiteSpace($Raw)) {
$Parsed = $Raw | ConvertFrom-Json -Depth 20
if ($Parsed) {
$SettingsObject = $Parsed
}
}
}
catch {
Write-Host " ! Could not parse $SettingsPath"
Write-Host " Add this manually later under mcp.servers.a11y-agent-team.url = $Url"
return
}
}
if ($SettingsObject.PSObject.Properties.Name -notcontains "mcp") {
$SettingsObject | Add-Member -NotePropertyName "mcp" -NotePropertyValue ([PSCustomObject]@{})
}
$McpSettings = $SettingsObject.mcp
if ($McpSettings.PSObject.Properties.Name -notcontains "servers") {
$McpSettings | Add-Member -NotePropertyName "servers" -NotePropertyValue ([PSCustomObject]@{})
}
$ServerSettings = $McpSettings.servers
if ($ServerSettings.PSObject.Properties.Name -notcontains "a11y-agent-team") {
$ServerSettings | Add-Member -NotePropertyName "a11y-agent-team" -NotePropertyValue ([PSCustomObject]@{})
}
$A11yServer = $ServerSettings.'a11y-agent-team'
if ($A11yServer.PSObject.Properties.Name -contains "url") {
$A11yServer.url = $Url
}
else {
$A11yServer | Add-Member -NotePropertyName "url" -NotePropertyValue $Url
}
$SettingsObject | ConvertTo-Json -Depth 20 | Set-Content $SettingsPath -Encoding UTF8
Write-Host " + MCP server registered in $SettingsPath"
}
function Get-NodeMajorVersion {
$NodeCmd = Get-Command node -ErrorAction SilentlyContinue
if (-not $NodeCmd) {
return $null
}
try {
return [int](& node -p "process.versions.node.split('.')[0]" 2>$null)
}
catch {
return $null
}
}
function Get-JavaMajorVersion {
$JavaCmd = Get-Command java -ErrorAction SilentlyContinue
if (-not $JavaCmd) {
return $null
}
try {
$JavaVersionLine = (& java -version 2>&1 | Select-Object -First 1)
}
catch {
return $null
}
if ($JavaVersionLine -match '"(?<major>\d+)(?:\.(?<minor>\d+))?') {
$Major = [int]$matches['major']
if ($Major -eq 1 -and $matches['minor']) {
return [int]$matches['minor']
}
return $Major
}
if ($JavaVersionLine -match '\b(?<major>\d+)\b') {
return [int]$matches['major']
}
return $null
}
function Refresh-ProcessPath {
$MachinePath = [System.Environment]::GetEnvironmentVariable("Path", "Machine")
$UserPath = [System.Environment]::GetEnvironmentVariable("Path", "User")
$env:Path = ($MachinePath, $UserPath -join ";")
}
$VsCodeProfileMode = Get-RequestedProfileMode -Stable:$VsCodeStable -Insiders:$VsCodeInsiders -Both:$VsCodeBoth
$McpProfileMode = Get-RequestedProfileMode -Stable:$McpProfileStable -Insiders:$McpProfileInsiders -Both:$McpProfileBoth
$DetectedVsCodeProfiles = @(Get-VSCodeProfiles)
$SelectedCopilotProfiles = @(Select-VSCodeProfiles -Profiles $DetectedVsCodeProfiles -Mode $VsCodeProfileMode -OnlyExisting)
$SelectedMcpProfiles = @(Select-VSCodeProfiles -Profiles $DetectedVsCodeProfiles -Mode $McpProfileMode -OnlyExisting)
if (-not $SummaryPath) {
$SummaryName = if ($DryRun -or $Check) { '.a11y-agent-team-install-plan.json' } else { '.a11y-agent-team-install-summary.json' }
$SummaryRoot = if ($Choice -eq '1') { (Get-Location).Path } else { $env:USERPROFILE }
$SummaryPath = Join-Path $SummaryRoot $SummaryName
}
$OperationRoot = if ($Choice -eq '1') { (Get-Location).Path } else { $env:USERPROFILE }
$BackupMetadataPath = Initialize-A11yOperationState -Operation 'install' -Root $OperationRoot -SummaryPath $SummaryPath -DryRun $DryRun -CheckMode $Check -CandidatePaths @($TargetDir, (Join-Path $TargetDir '.a11y-agent-manifest'), (Join-Path $TargetDir '.a11y-agent-team-version'))
$InstallSummary = [ordered]@{
schemaVersion = '1.0'
timestampUtc = (Get-Date).ToUniversalTime().ToString('yyyy-MM-ddTHH:mm:ssZ')
operation = 'install'
dryRun = [bool]$DryRun
check = [bool]$Check
scope = if ($Choice -eq '1') { 'project' } else { 'global' }
targetDir = $TargetDir
requestedOptions = [ordered]@{
copilot = [bool]$Copilot
copilotCli = [bool]$Cli
codex = [bool]$Codex
gemini = [bool]$Gemini
autoApprove = [bool]$Yes
noAutoUpdate = [bool]$NoAutoUpdate
vscodeProfileMode = $VsCodeProfileMode
mcpProfileMode = $McpProfileMode
}
detectedVsCodeProfiles = @($DetectedVsCodeProfiles | ForEach-Object {
[ordered]@{
key = $_.Key
name = $_.Name
path = $_.Path
exists = [bool]$_.Exists
}
})
selectedCopilotProfiles = @($SelectedCopilotProfiles | ForEach-Object { $_.Path })
selectedMcpProfiles = @($SelectedMcpProfiles | ForEach-Object { $_.Path })
backupMetadataPath = $BackupMetadataPath
notes = @()
}
if ($Check) {
$InstallSummary.notes += 'Check mode only. No files were changed.'
Write-Host ''
Write-Host ' Check mode only. No files will be changed.'
Write-Host " Scope: $($InstallSummary.scope)"
Write-Host " Target: $TargetDir"
Write-Host " Backup metadata: $BackupMetadataPath"
Write-Host " Detected VS Code profiles: $($DetectedVsCodeProfiles.Count)"
Write-InstallSummaryFile -Path $SummaryPath -Data $InstallSummary
Write-Host " Summary file: $SummaryPath"
exit 0
}
if ($DryRun) {
if (-not ($Copilot -or $Cli -or $Codex -or $Gemini)) {
$InstallSummary.notes += 'Optional platforms were not selected in dry-run mode. Use -Copilot, -Cli, -Codex, and/or -Gemini to preview them explicitly.'
}
Write-Host ''
Write-Host ' Dry run only. No files will be changed.'
Write-Host " Scope: $($InstallSummary.scope)"
Write-Host " Target: $TargetDir"
if ($Choice -eq '2') {
Write-Host ' VS Code profiles in scope:'
if ($SelectedCopilotProfiles.Count -gt 0) {
foreach ($Profile in $SelectedCopilotProfiles) {
Write-Host " -> $($Profile.Name): $($Profile.Path)"
}
}
else {
Write-Host ' -> none detected for the requested profile filter'
}
Write-Host ' MCP settings targets:'
if ($SelectedMcpProfiles.Count -gt 0) {
foreach ($Profile in $SelectedMcpProfiles) {
Write-Host " -> $($Profile.Name): $(Join-Path $Profile.Path 'settings.json')"
}
}
else {
Write-Host ' -> none detected for the requested profile filter'
}
}
Write-Host " Summary file: $SummaryPath"
Write-InstallSummaryFile -Path $SummaryPath -Data $InstallSummary
exit 0
}
function Read-YesNo {
param(
[string]$Prompt,
[bool]$DefaultYes = $false
)
if ($AutoApprove) {
return $true
}
if (-not (Test-InteractivePrompting)) {
return $DefaultYes
}
$Suffix = if ($DefaultYes) { '[Y/n]' } else { '[y/N]' }
$Answer = Read-Host " $Prompt $Suffix"
if ([string]::IsNullOrWhiteSpace($Answer)) {
return $DefaultYes
}
return ($Answer -eq 'y' -or $Answer -eq 'Y')
}
function Get-McpCapabilityPlan {
if ($AutoApprove -or -not (Test-InteractivePrompting)) {
return [PSCustomObject]@{
Focus = 'Baseline scanning'
BrowserTools = $false
PdfForms = $false
DeepPdf = $false
ConfigureVsCode = $true
}
}
Write-Host ""
Write-Host " Choose your MCP setup focus:"
Write-Host ""
Write-Host " 1) Baseline scanning - document and PDF scanning only"
Write-Host " 2) Browser testing - baseline plus Playwright browser tools"
Write-Host " 3) PDF-heavy workflow - baseline plus deep PDF and form tools"
Write-Host " 4) Everything - install every MCP capability we support"
Write-Host " 5) Custom - choose capabilities one by one"
Write-Host ""
$Choice = Read-Host " Choose [1/2/3/4/5]"
$Plan = [ordered]@{
Focus = 'Baseline scanning'
BrowserTools = $false
PdfForms = $false
DeepPdf = $false
ConfigureVsCode = $true
}
switch ($Choice) {
'2' {
$Plan.Focus = 'Browser testing'
$Plan.BrowserTools = $true
}
'3' {
$Plan.Focus = 'PDF-heavy workflow'
$Plan.PdfForms = $true
$Plan.DeepPdf = $true
}
'4' {
$Plan.Focus = 'Everything'
$Plan.BrowserTools = $true
$Plan.PdfForms = $true
$Plan.DeepPdf = $true
}
'5' {
$Plan.Focus = 'Custom'
$Plan.BrowserTools = Read-YesNo -Prompt 'Enable browser-based accessibility tools now?' -DefaultYes:$false
$Plan.PdfForms = Read-YesNo -Prompt 'Enable PDF form conversion tools now?' -DefaultYes:$false
$Plan.DeepPdf = Read-YesNo -Prompt 'Prepare deep PDF validation tools now?' -DefaultYes:$false
$Plan.ConfigureVsCode = Read-YesNo -Prompt 'Configure VS Code MCP settings automatically?' -DefaultYes:$true
}
}
return [PSCustomObject]$Plan
}
function Show-McpCapabilityWarnings {
param([object]$Plan)
Write-Host ""
Write-Host " MCP capability plan: $($Plan.Focus)"
Write-Host " - Baseline scanning installs the MCP server plus core npm dependencies"
if ($Plan.BrowserTools) {
Write-Host " - Browser testing needs Playwright, axe-core, and Chromium"
Write-Host " - Browser scans run against live pages and can take longer to install"
}
if ($Plan.PdfForms) {
Write-Host " - PDF form conversion needs the optional pdf-lib package"
}
if ($Plan.DeepPdf) {
Write-Host " - Deep PDF validation needs Java 11+ and veraPDF"
Write-Host " - Baseline PDF scanning still works even if deep validation is not ready"
}
Write-Host " - Python is not required for MCP runtime"
Write-Host " - macOS is supported by the shell installer; Linux is not part of the guided installer target"
}
function Ensure-NodeJsRuntime {
$NodeCmd = Get-Command node -ErrorAction SilentlyContinue
$NpmCmd = Get-Command npm -ErrorAction SilentlyContinue
$NodeMajor = Get-NodeMajorVersion
if ($NodeCmd -and $NpmCmd -and $NodeMajor -ge 18) {
return $true
}
Write-Host ""
if ($NodeCmd -and $NodeMajor) {
Write-Host " Detected Node.js $NodeMajor, but the MCP server requires Node.js 18 or later."
}
else {
Write-Host " Node.js and npm were not found."
}
$WingetCmd = Get-Command winget -ErrorAction SilentlyContinue
if ($WingetCmd) {
Write-Host " The installer can install Node.js LTS with winget."
if (Read-YesNo -Prompt 'Install Node.js LTS now?' -DefaultYes:$true) {
try {
winget install --exact --id OpenJS.NodeJS.LTS --accept-package-agreements --accept-source-agreements 2>&1 | Out-Null
if ($LASTEXITCODE -ne 0) { throw "winget install failed with exit code $LASTEXITCODE" }
Refresh-ProcessPath
}
catch {
Write-Host " ! Node.js installation via winget failed."
}
}
}
else {
Write-Host " winget was not found, so Node.js cannot be installed automatically here."
}
$NodeCmd = Get-Command node -ErrorAction SilentlyContinue
$NpmCmd = Get-Command npm -ErrorAction SilentlyContinue
$NodeMajor = Get-NodeMajorVersion
if ($NodeCmd -and $NpmCmd -and $NodeMajor -ge 18) {
Write-Host " + Node.js runtime is ready for the MCP server"
return $true
}
Write-Host " MCP setup can continue, but scanning will remain unavailable until Node.js 18+ and npm are installed."
Write-Host " Manual fallback: https://nodejs.org/en/download"
Write-Host " After installing Node.js, reopen your terminal and run:"
Write-Host " cd \"$McpDest\""
Write-Host " npm install"
return $false
}
function Show-PdfDeepValidationReadiness {
$JavaCmd = Get-Command java -ErrorAction SilentlyContinue
$VeraPdfCmd = Get-Command verapdf -ErrorAction SilentlyContinue
$JavaMajor = Get-JavaMajorVersion
Write-Host ""
Write-Host " PDF Deep Validation Readiness:"
if ($JavaCmd) {
try {
$JavaVersion = (& java -version 2>&1 | Select-Object -First 1)
if ($JavaMajor -ge 11) {
Write-Host " [x] Java detected: $JavaVersion"
}
else {
Write-Host " [!] Java detected but too old: $JavaVersion"
}
}
catch {
if ($JavaMajor -ge 11) {
Write-Host " [x] Java command found"
}
else {
Write-Host " [!] Java command found, but version could not be confirmed as 11+"
}
}
}
else {
Write-Host " [ ] Java not detected"
}
if ($VeraPdfCmd) {
try {
$VeraPdfVersion = (& verapdf --version 2>&1 | Select-Object -First 1)
Write-Host " [x] veraPDF detected: $VeraPdfVersion"
}
catch {
Write-Host " [x] veraPDF command found"
}
}
else {
Write-Host " [ ] veraPDF not detected"
}
if ($JavaCmd -and $JavaMajor -ge 11 -and $VeraPdfCmd) {
Write-Host " READY: run_verapdf_scan should be available once the MCP server is running."
}
elseif ($JavaCmd -and $JavaMajor -ge 11) {
Write-Host " PARTIAL: Java is ready, but veraPDF still needs to be installed."
}
elseif ($JavaCmd) {
Write-Host " NOT READY: Java 11 or later is required before veraPDF can run."
}
else {
Write-Host " NOT READY: scan_pdf_document will work, but run_verapdf_scan will not yet be available."
}
}
function Test-McpHealthSmoke {
param([string]$WorkingDir)
$NodeCmd = Get-Command node -ErrorAction SilentlyContinue
$NpmCmd = Get-Command npm -ErrorAction SilentlyContinue
$NodeMajor = Get-NodeMajorVersion
$CoreSdkReady = Test-NodeModuleAvailable -WorkingDir $WorkingDir -ModuleName '@modelcontextprotocol/sdk'
$CoreSchemaReady = Test-NodeModuleAvailable -WorkingDir $WorkingDir -ModuleName 'zod'
if (-not ($NodeCmd -and $NpmCmd -and $NodeMajor -ge 18 -and $CoreSdkReady -and $CoreSchemaReady)) {
return [PSCustomObject]@{
Label = '[ ] SKIPPED'
Detail = 'Baseline MCP prerequisites are not fully installed yet.'
}
}
$Port = 4300 + (Get-Random -Minimum 0 -Maximum 200)
$StdOut = [System.IO.Path]::GetTempFileName()
$StdErr = [System.IO.Path]::GetTempFileName()
$Process = $null
try {
$Command = "set PORT=$Port&& set A11Y_MCP_HOST=127.0.0.1&& set A11Y_MCP_STATELESS=1&& node server.js"
$Process = Start-Process -FilePath 'cmd.exe' -ArgumentList '/c', $Command -WorkingDirectory $WorkingDir -RedirectStandardOutput $StdOut -RedirectStandardError $StdErr -WindowStyle Hidden -PassThru
for ($Attempt = 0; $Attempt -lt 20; $Attempt++) {
Start-Sleep -Milliseconds 500
try {
$Response = Invoke-RestMethod -Uri "http://127.0.0.1:$Port/health" -Method Get -TimeoutSec 2
if ($Response.status -eq 'ok') {
return [PSCustomObject]@{
Label = '[x] READY'
Detail = "HTTP health check passed on port $Port."
}
}
}
catch {
}
}
$ErrorLine = ''
if (Test-Path $StdErr) {
$ErrorLine = Get-Content $StdErr -ErrorAction SilentlyContinue | Select-Object -First 1
}
if (-not $ErrorLine -and (Test-Path $StdOut)) {
$ErrorLine = Get-Content $StdOut -ErrorAction SilentlyContinue | Select-Object -First 1
}
if (-not $ErrorLine) {
$ErrorLine = 'The temporary MCP server did not answer /health in time.'
}
return [PSCustomObject]@{
Label = '[ ] FAILED'
Detail = $ErrorLine
}
}
finally {
if ($Process -and -not $Process.HasExited) {
Stop-Process -Id $Process.Id -Force -ErrorAction SilentlyContinue
}
Remove-Item $StdOut, $StdErr -Force -ErrorAction SilentlyContinue
}
}
function Test-NodeModuleAvailable {
param([string]$WorkingDir, [string]$ModuleName)
if (-not $WorkingDir -or -not (Test-Path $WorkingDir)) {
return $false
}
$ModulePkgPath = Join-Path $WorkingDir "node_modules" $ModuleName "package.json"
return (Test-Path $ModulePkgPath)
}
function Test-PlaywrightChromiumReady {
param([string]$WorkingDir)
$NodeCmd = Get-Command node -ErrorAction SilentlyContinue
if (-not $NodeCmd -or -not $WorkingDir -or -not (Test-Path $WorkingDir)) {
return $false
}
try {
Push-Location $WorkingDir
$null = node -e "import('playwright').then(async ({ chromium }) => { const fs = await import('node:fs'); const exe = chromium.executablePath(); process.exit(exe && fs.existsSync(exe) ? 0 : 1); }).catch(() => process.exit(1))" 2>&1
$Success = ($LASTEXITCODE -eq 0)
Pop-Location
return $Success
}
catch {
Pop-Location -ErrorAction SilentlyContinue
return $false
}
}
function Show-McpCapabilityReadiness {
param([string]$WorkingDir)
$NodeCmd = Get-Command node -ErrorAction SilentlyContinue
$NpmCmd = Get-Command npm -ErrorAction SilentlyContinue
$NodeMajor = Get-NodeMajorVersion
$JavaMajor = Get-JavaMajorVersion
$JavaCmd = Get-Command java -ErrorAction SilentlyContinue
$VeraPdfCmd = Get-Command verapdf -ErrorAction SilentlyContinue
$CoreSdkReady = Test-NodeModuleAvailable -WorkingDir $WorkingDir -ModuleName '@modelcontextprotocol/sdk'
$CoreSchemaReady = Test-NodeModuleAvailable -WorkingDir $WorkingDir -ModuleName 'zod'
$PlaywrightReady = Test-NodeModuleAvailable -WorkingDir $WorkingDir -ModuleName 'playwright'
$PdfLibReady = Test-NodeModuleAvailable -WorkingDir $WorkingDir -ModuleName 'pdf-lib'
$ChromiumReady = Test-PlaywrightChromiumReady -WorkingDir $WorkingDir
$BaselineReady = ($NodeCmd -and $NpmCmd -and $NodeMajor -ge 18 -and $CoreSdkReady -and $CoreSchemaReady)
$SmokeTest = Test-McpHealthSmoke -WorkingDir $WorkingDir
Write-Host ""
Write-Host " MCP Optional Capability Readiness:"
if ($NodeCmd -and $NodeMajor) {
Write-Host (" Node.js runtime (18+): " + ($(if ($NodeMajor -ge 18) { "[x] READY (v$NodeMajor)" } else { "[!] TOO OLD (v$NodeMajor)" })))
}
else {
Write-Host " Node.js runtime (18+): [ ] NOT READY"
}
Write-Host (" npm CLI: " + ($(if ($NpmCmd) { '[x] READY' } else { '[ ] NOT READY' })))
Write-Host (" MCP core dependencies: " + ($(if ($CoreSdkReady -and $CoreSchemaReady) { '[x] READY' } else { '[ ] NOT READY' })))
Write-Host " Python 3 helper (installer only): [~] NOT REQUIRED ON WINDOWS"
Write-Host (" Baseline PDF scan (scan_pdf_document): " + ($(if ($BaselineReady) { '[x] READY' } else { '[ ] NOT READY' })))
if ($JavaCmd -and $JavaMajor) {
Write-Host (" Deep PDF validation (Java 11+): " + ($(if ($JavaMajor -ge 11) { "[x] READY (v$JavaMajor)" } else { "[!] TOO OLD (v$JavaMajor)" })))
}
else {
Write-Host " Deep PDF validation (Java 11+): [ ] NOT READY"
}
Write-Host (" Deep PDF validation (veraPDF): " + ($(if ($VeraPdfCmd) { '[x] READY' } else { '[ ] NOT READY' })))
Write-Host (" Local MCP health smoke test: " + $SmokeTest.Label)
Write-Host (" Playwright package: " + ($(if ($PlaywrightReady) { '[x] READY' } else { '[ ] NOT READY' })))
Write-Host (" Chromium browser bundle: " + ($(if ($ChromiumReady) { '[x] READY' } else { '[ ] NOT READY' })))
Write-Host (" PDF form conversion (pdf-lib): " + ($(if ($PdfLibReady) { '[x] READY' } else { '[ ] NOT READY' })))
if (-not $BaselineReady) {
Write-Host " Baseline scanning needs Node.js 18+, npm, and MCP server dependencies in the MCP directory."
}
Write-Host " Python is not required for MCP runtime on Windows."
if ($SmokeTest.Detail) {
Write-Host " Smoke test detail: $($SmokeTest.Detail)"
}
if (-not $PlaywrightReady -or -not $ChromiumReady) {
Write-Host " Browser-based scans need Playwright plus Chromium."
}
if (-not $PdfLibReady) {
Write-Host " PDF form conversion needs pdf-lib in the MCP server directory."
}
}
# ---------------------------------------------------------------------------
# Migrate-Prompts: rename old prompt filenames to new agent-matching names.
# This ensures users upgrading from v2.x to v3.0 don't lose custom prompts.
# Migration: old naming (task-based) -> new naming (agent-based)
# ---------------------------------------------------------------------------
function Migrate-Prompts {
param([string]$SrcDir)
if (-not (Test-Path $SrcDir)) { return }
$migrations = @{
"a11y-update.prompt.md" = "insiders-a11y-tracker.prompt.md"
"audit-desktop-a11y.prompt.md" = "desktop-a11y-specialist.prompt.md"
"audit-markdown.prompt.md" = "markdown-a11y-assistant.prompt.md"
"audit-web-page.prompt.md" = "web-accessibility-wizard.prompt.md"
"export-document-csv.prompt.md" = "document-csv-reporter.prompt.md"
"export-markdown-csv.prompt.md" = "markdown-csv-reporter.prompt.md"
"export-web-csv.prompt.md" = "web-csv-reporter.prompt.md"
"package-python-app.prompt.md" = "python-specialist.prompt.md"
"review-text-quality.prompt.md" = "text-quality-reviewer.prompt.md"
"scaffold-nvda-addon.prompt.md" = "nvda-addon-specialist.prompt.md"
"scaffold-wxpython-app.prompt.md" = "wxpython-specialist.prompt.md"
"test-desktop-a11y.prompt.md" = "desktop-a11y-testing-coach.prompt.md"
}
foreach ($oldName in $migrations.Keys) {
$newName = $migrations[$oldName]
$oldFile = Join-Path $SrcDir $oldName
$newFile = Join-Path $SrcDir $newName
if ((Test-Path $oldFile) -and -not (Test-Path $newFile)) {
Rename-Item -Path $oldFile -NewName $newName -ErrorAction SilentlyContinue
}
elseif ((Test-Path $oldFile) -and (Test-Path $newFile)) {
# Both exist; remove old version and keep new
Remove-Item -Path $oldFile -Force -ErrorAction SilentlyContinue
}
}
}
# ---------------------------------------------------------------------------
# Install-GlobalHooks: installs three enforcement hooks for Claude Code.
# 1. a11y-team-eval.sh (UserPromptSubmit) - Proactive web project detection
# 2. a11y-enforce-edit.sh (PreToolUse) - Blocks UI file edits without review
# 3. a11y-mark-reviewed.sh (PostToolUse) - Creates session marker after review
# ---------------------------------------------------------------------------
function Install-GlobalHooks {
$HooksDir = Join-Path $env:USERPROFILE ".claude\hooks"
$SettingsJson = Join-Path $env:USERPROFILE ".claude\settings.json"
$HookSrc = Join-Path $ScriptDir "claude-code-plugin\scripts"
if (-not (Test-Path $HookSrc)) {
$HookSrc = Join-Path $ScriptDir ".claude\hooks"
}
if (-not (Test-Path $HookSrc)) {
Write-Host " (hook scripts not found - skipping)"
return
}
New-Item -ItemType Directory -Force -Path $HooksDir | Out-Null
# Resolve bash path - Git for Windows may not add bash.exe to PATH
$BashCmd = "bash"
if (-not (Get-Command bash -ErrorAction SilentlyContinue)) {
$GitCmd = Get-Command git -ErrorAction SilentlyContinue
if ($GitCmd) {
$GitBin = Join-Path (Split-Path (Split-Path $GitCmd.Source)) "bin\bash.exe"
if (Test-Path $GitBin) {
$BashCmd = $GitBin.Replace('\', '/')
}
else {
Write-Host " Warning: bash not found in PATH or Git install. Hooks may not execute."
}
}
}
# Forward-slash path for bash on Windows (Git Bash requires forward slashes)
$HooksDirFwd = $HooksDir.Replace('\', '/')
foreach ($Hook in @("a11y-team-eval.sh", "a11y-enforce-edit.sh", "a11y-mark-reviewed.sh")) {
$Src = Join-Path $HookSrc $Hook
$Dst = Join-Path $HooksDir $Hook
if (Test-Path $Src) {
Copy-Item -Path $Src -Destination $Dst -Force
}
}
# Register hooks in settings.json
if (-not (Test-Path $SettingsJson)) {
[IO.File]::WriteAllText($SettingsJson, "{}", [Text.Encoding]::UTF8)
}
# Helper: upsert a hook entry by matching a substring in the command
function Set-HookEntry {
param([string]$EventName, [string]$MatchSubstr, [hashtable]$NewEntry)
$Settings = Get-Content $SettingsJson -Raw | ConvertFrom-Json
if (-not $Settings.PSObject.Properties["hooks"]) {
$Settings | Add-Member -NotePropertyName "hooks" -NotePropertyValue ([PSCustomObject]@{})
}
$Hooks = $Settings.hooks
if (-not $Hooks.PSObject.Properties[$EventName]) {
$Hooks | Add-Member -NotePropertyName $EventName -NotePropertyValue @()
}
$Entries = @($Hooks.$EventName)
$Replaced = $false
for ($i = 0; $i -lt $Entries.Count; $i++) {
foreach ($h in $Entries[$i].hooks) {
if ($h.command -and $h.command.Contains($MatchSubstr)) {
$Entries[$i] = $NewEntry
$Replaced = $true
break
}
}
if ($Replaced) { break }
}
if (-not $Replaced) { $Entries += $NewEntry }
$Hooks.$EventName = $Entries
$Settings | ConvertTo-Json -Depth 10 | Set-Content $SettingsJson -Encoding UTF8
}
Set-HookEntry -EventName "UserPromptSubmit" -MatchSubstr "a11y-team-eval" -NewEntry @{
hooks = @(@{ type = "command"; command = "$BashCmd `"$HooksDirFwd/a11y-team-eval.sh`"" })
}
Set-HookEntry -EventName "PreToolUse" -MatchSubstr "a11y-enforce-edit" -NewEntry @{
matcher = "Edit|Write"
hooks = @(@{ type = "command"; command = "$BashCmd `"$HooksDirFwd/a11y-enforce-edit.sh`"" })
}
Set-HookEntry -EventName "PostToolUse" -MatchSubstr "a11y-mark-reviewed" -NewEntry @{
matcher = "Agent"
hooks = @(@{ type = "command"; command = "$BashCmd `"$HooksDirFwd/a11y-mark-reviewed.sh`"" })
}
Write-Host " + Hook 1: a11y-team-eval.sh (UserPromptSubmit - proactive web detection)"
Write-Host " + Hook 2: a11y-enforce-edit.sh (PreToolUse - blocks UI edits without review)"
Write-Host " + Hook 3: a11y-mark-reviewed.sh (PostToolUse - unlocks after review)"
Write-Host " + All 3 hooks registered in settings.json"
}
# Create directories
New-Item -ItemType Directory -Force -Path (Join-Path $TargetDir "agents") | Out-Null
# Track which files we install so the uninstaller can cleanly remove everything.
# The manifest is the single source of truth for what belongs to us vs. user files.
$ManifestPath = Join-Path $TargetDir ".a11y-agent-manifest"
$Manifest = [System.Collections.Generic.List[string]]::new()
if (Test-Path $ManifestPath) {
[IO.File]::ReadAllLines($ManifestPath, [Text.Encoding]::UTF8) | Where-Object { $_.Trim() -ne "" } | ForEach-Object { $Manifest.Add($_) }
}
function Add-ManifestEntry([string]$Entry) {
if (-not $Manifest.Contains($Entry)) { $Manifest.Add($Entry) }
}
function Save-Manifest {
[IO.File]::WriteAllLines($ManifestPath, $Manifest.ToArray(), [Text.Encoding]::UTF8)
}
# Copy agents - skip any file that already exists (preserves user customisations)
Write-Host ""
Write-Host " Copying agents..."
$SkippedAgents = 0
foreach ($Agent in $Agents) {
$Src = Join-Path $AgentsSrc $Agent
$Dst = Join-Path $TargetDir "agents\$Agent"
$Name = $Agent -replace '\.md$', ''
if (Test-Path $Dst) {
Write-Host " ~ $Name (skipped - already exists)"
$SkippedAgents++
}
else {
Copy-Item -Path $Src -Destination $Dst
Add-ManifestEntry "agents/$Agent"
Write-Host " + $Name"
}
}
if ($SkippedAgents -gt 0) {
Write-Host " $SkippedAgents agent(s) skipped. Use -Force flag or delete them first to reinstall."
}
# Save manifest (will be updated again as more platforms are installed)
Save-Manifest
# Copilot agents
$CopilotInstalled = $false
$CopilotDestinations = @()
$InstallCopilot = $Copilot.IsPresent
if ((-not $InstallCopilot) -and (-not $OptionalPlatformFlags) -and (-not $AutoApprove) -and (Read-YesNo -Prompt 'Install Copilot agents?' -DefaultYes:$false)) {
Write-Host ""
Write-Host " Would you also like to install GitHub Copilot agents?"
Write-Host " This adds accessibility agents for Copilot Chat in VS Code/GitHub."
$InstallCopilot = $true
}
if ($InstallCopilot) {
if ($Choice -eq "1") {
# Project install: put agents in .github\agents\
$ProjectDir = Get-Location
$CopilotDst = Join-Path $ProjectDir ".github\agents"
New-Item -ItemType Directory -Force -Path $CopilotDst | Out-Null
$CopilotDestinations += $CopilotDst
# Merge Copilot config files - appends our section rather than overwriting
Write-Host ""
Write-Host " Merging Copilot config..."
foreach ($Config in @("copilot-instructions.md", "copilot-review-instructions.md", "copilot-commit-message-instructions.md")) {
$Src = Join-Path $CopilotConfigSrc $Config
$Dst = Join-Path $ProjectDir ".github\$Config"
if (Test-Path $Src) {
Merge-ConfigFile -SrcFile $Src -DstFile $Dst -Label $Config
}
}
# Copy Copilot agents - skip files that already exist (preserves user agents)
Write-Host ""
Write-Host " Copying Copilot agents..."
if (Test-Path $CopilotAgentsSrc) {
foreach ($File in Get-ChildItem -Path $CopilotAgentsSrc -File) {
$DstPath = Join-Path $CopilotDst $File.Name
$DisplayName = $File.BaseName -replace '\.agent$', ''
if (Test-Path $DstPath) {
Write-Host " ~ $DisplayName (skipped - already exists)"
}
else {
Copy-Item -Path $File.FullName -Destination $DstPath
Add-ManifestEntry "copilot-agents/$($File.Name)"
Write-Host " + $DisplayName"
}
}
}
# Copy Copilot asset subdirs - file-by-file, skipping files that already exist
Write-Host ""
Write-Host " Copying Copilot assets..."
foreach ($SubDir in @("skills", "instructions", "prompts")) {
$SrcSubDir = Join-Path $CopilotConfigSrc $SubDir
$DstSubDir = Join-Path $ProjectDir ".github\$SubDir"
if (Test-Path $SrcSubDir) {
# Migrate old prompt names to new agent-matching names (v2.5 -> v2.6)
if ($SubDir -eq "prompts") {
Migrate-Prompts -SrcDir $SrcSubDir
}
New-Item -ItemType Directory -Force -Path $DstSubDir | Out-Null
$Added = 0; $Skipped = 0
foreach ($File in Get-ChildItem -Recurse -File $SrcSubDir) {
$Rel = $File.FullName.Substring($SrcSubDir.Length).TrimStart('\\')
$Dst = Join-Path $DstSubDir $Rel
New-Item -ItemType Directory -Force -Path (Split-Path $Dst) | Out-Null
if (Test-Path $Dst) { $Skipped++ } else {
Copy-Item $File.FullName $Dst
$RelEntry = $Rel.Replace('\\', '/')
Add-ManifestEntry "copilot-$SubDir/$RelEntry"
$Added++
}
}
$msg = " + .github\$SubDir\ ($Added new"
if ($Skipped -gt 0) { $msg += ", $Skipped skipped" }
Write-Host "$msg)"
}
}
Add-ManifestEntry "copilot-config/copilot-instructions.md"
Add-ManifestEntry "copilot-config/copilot-review-instructions.md"
Add-ManifestEntry "copilot-config/copilot-commit-message-instructions.md"
Save-Manifest
$CopilotInstalled = $true
}
else {
# Global install: store Copilot agents centrally and configure VS Code
# to discover them via chat.agentFilesLocations setting.
$CopilotCentral = Join-Path $env:USERPROFILE ".a11y-agent-team\copilot-agents"
New-Item -ItemType Directory -Force -Path $CopilotCentral | Out-Null