-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathuninstall.sh
More file actions
executable file
·762 lines (715 loc) · 25.4 KB
/
uninstall.sh
File metadata and controls
executable file
·762 lines (715 loc) · 25.4 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
#!/bin/bash
# Accessibility Agents Uninstaller
# Built by Community Access - https://community-access.org
#
# Usage:
# bash uninstall.sh Interactive mode
# bash uninstall.sh --global Uninstall from ~/.claude/
# bash uninstall.sh --project Uninstall from .claude/ in the current directory
# bash uninstall.sh --dry-run Preview targets without removing files
# bash uninstall.sh --vscode-stable|--vscode-insiders|--vscode-both
# bash uninstall.sh --summary=path.json
#
# One-liner:
# curl -fsSL https://raw.githubusercontent.com/Community-Access/accessibility-agents/main/uninstall.sh | bash
# curl -fsSL ... | bash -s -- --global (non-interactive)
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" 2>/dev/null && pwd)"
. "$SCRIPT_DIR/scripts/installer-common.sh"
enforce_shell_runtime
# Parse flags
choice=""
DRY_RUN=false
CHECK_MODE=false
SUMMARY_PATH=""
VSCODE_PROFILE_MODE="auto"
for arg in "$@"; do
case "$arg" in
--global) choice="2" ;;
--project) choice="1" ;;
--check) CHECK_MODE=true ;;
--dry-run) DRY_RUN=true ;;
--vscode-stable) VSCODE_PROFILE_MODE=$(set_profile_mode "$VSCODE_PROFILE_MODE" "stable") ;;
--vscode-insiders) VSCODE_PROFILE_MODE=$(set_profile_mode "$VSCODE_PROFILE_MODE" "insiders") ;;
--vscode-both) VSCODE_PROFILE_MODE=$(set_profile_mode "$VSCODE_PROFILE_MODE" "both") ;;
--summary=*) SUMMARY_PATH="${arg#--summary=}" ;;
esac
done
if [ -z "$choice" ]; then
if ! { true < /dev/tty; } 2>/dev/null; then
echo " Error: No terminal available for interactive mode."
echo " Use: curl ... | bash -s -- --global"
echo " or: curl ... | bash -s -- --project"
exit 1
fi
echo ""
echo " Accessibility Agents Uninstaller"
echo " ================================"
echo ""
echo " Where would you like to uninstall from?"
echo ""
echo " 1) Project - Remove from .claude/ in the current directory"
echo " 2) Global - Remove from ~/.claude/"
echo ""
printf " Choose [1/2]: "
read -r choice < /dev/tty
fi
case "$choice" in
1)
TARGET_DIR="$(pwd)/.claude"
PROJECT_DIR="$(pwd)"
echo ""
echo " Uninstalling from project: $(pwd)"
;;
2)
TARGET_DIR="$HOME/.claude"
PROJECT_DIR=""
echo ""
echo " Uninstalling from: $TARGET_DIR"
;;
*)
echo " Invalid choice. Exiting."
exit 1
;;
esac
SELECTED_VSCODE_PROFILES="$(select_vscode_profiles "$VSCODE_PROFILE_MODE")"
if [ -z "$SUMMARY_PATH" ]; then
if [ "$DRY_RUN" = true ] || [ "$CHECK_MODE" = true ]; then
SUMMARY_PATH="$HOME/.a11y-agent-team-uninstall-plan.json"
elif [ "$choice" = "1" ]; then
SUMMARY_PATH="$(pwd)/.a11y-agent-team-uninstall-summary.json"
else
SUMMARY_PATH="$HOME/.a11y-agent-team-uninstall-summary.json"
fi
fi
BACKUP_METADATA_PATH="$(initialize_operation_state uninstall "$([ "$choice" = "1" ] && pwd || printf '%s' "$HOME")" "$SUMMARY_PATH" "$DRY_RUN" "$CHECK_MODE" "$TARGET_DIR" "$TARGET_DIR/.a11y-agent-manifest" "$TARGET_DIR/.a11y-agent-team-version")"
if [ "$CHECK_MODE" = true ]; then
write_summary_file "$SUMMARY_PATH" "{\"schemaVersion\":\"1.0\",\"timestampUtc\":\"$(date -u +%Y-%m-%dT%H:%M:%SZ)\",\"operation\":\"uninstall\",\"dryRun\":false,\"check\":true,\"scope\":\"$([ \"$choice\" = \"1\" ] && echo project || echo global)\",\"targetDir\":\"$(json_escape "$TARGET_DIR")\",\"requestedOptions\":{\"vscodeProfileMode\":\"$VSCODE_PROFILE_MODE\"},\"backupMetadataPath\":\"$(json_escape "$BACKUP_METADATA_PATH")\",\"notes\":[\"Check mode only. No files were removed.\"] }"
echo " Summary file: $SUMMARY_PATH"
exit 0
fi
if [ "$DRY_RUN" = true ]; then
echo ""
echo " Dry run only. No files will be removed."
echo " Scope: $([ "$choice" = "1" ] && echo project || echo global)"
echo " Target: $TARGET_DIR"
if [ "$choice" = "2" ]; then
if [ -n "$SELECTED_VSCODE_PROFILES" ]; then
while IFS='|' read -r key label path; do
[ -n "$path" ] && echo " Would clean VS Code profile: $path"
done <<< "$SELECTED_VSCODE_PROFILES"
else
echo " No matching VS Code profiles detected for the requested filter."
fi
fi
write_summary_file "$SUMMARY_PATH" "{\"schemaVersion\":\"1.0\",\"timestampUtc\":\"$(date -u +%Y-%m-%dT%H:%M:%SZ)\",\"operation\":\"uninstall\",\"dryRun\":true,\"check\":false,\"scope\":\"$([ \"$choice\" = \"1\" ] && echo project || echo global)\",\"targetDir\":\"$(json_escape "$TARGET_DIR")\",\"requestedOptions\":{\"vscodeProfileMode\":\"$VSCODE_PROFILE_MODE\"},\"backupMetadataPath\":\"$(json_escape "$BACKUP_METADATA_PATH")\",\"notes\":[] }"
echo " Summary file: $SUMMARY_PATH"
exit 0
fi
# ---------------------------------------------------------------------------
# Load manifest — if missing, build a fallback list from the repo
# ---------------------------------------------------------------------------
MANIFEST_FILE="$TARGET_DIR/.a11y-agent-manifest"
MANIFEST_ENTRIES=()
FALLBACK_USED=false
if [ -f "$MANIFEST_FILE" ]; then
while IFS= read -r line; do
[ -n "$line" ] && MANIFEST_ENTRIES+=("$line")
done < "$MANIFEST_FILE"
echo " Loaded manifest with ${#MANIFEST_ENTRIES[@]} entries."
else
echo " No manifest found — building fallback list from repo..."
FALLBACK_USED=true
TMPDIR_REPO="$(mktemp -d)"
if git clone --quiet --depth 1 https://github.com/Community-Access/accessibility-agents.git "$TMPDIR_REPO/repo" 2>/dev/null; then
REPO="$TMPDIR_REPO/repo"
# Claude agents
for f in "$REPO"/.claude/agents/*.md; do
[ -f "$f" ] && MANIFEST_ENTRIES+=("agents/$(basename "$f")")
done
# Copilot agents
for f in "$REPO"/.github/agents/*; do
[ -f "$f" ] && MANIFEST_ENTRIES+=("copilot-agents/$(basename "$f")")
done
# Copilot assets
for subdir in skills instructions prompts; do
src_dir="$REPO/.github/$subdir"
if [ -d "$src_dir" ]; then
while IFS= read -r -d '' src_file; do
rel="${src_file#$src_dir/}"
MANIFEST_ENTRIES+=("copilot-$subdir/$rel")
done < <(find "$src_dir" -type f -print0)
fi
done
# Copilot config
for cfg in copilot-instructions.md copilot-review-instructions.md copilot-commit-message-instructions.md; do
[ -f "$REPO/.github/$cfg" ] && MANIFEST_ENTRIES+=("copilot-config/$cfg")
done
# Codex
if [ -f "$REPO/.codex/AGENTS.md" ]; then
MANIFEST_ENTRIES+=("codex/project")
MANIFEST_ENTRIES+=("codex/global")
fi
[ -f "$REPO/.codex/config.toml" ] && MANIFEST_ENTRIES+=("codex/config.toml")
if [ -d "$REPO/.codex/roles" ]; then
while IFS= read -r -d '' src_file; do
rel="${src_file#$REPO/.codex/roles/}"
MANIFEST_ENTRIES+=("codex/roles/$rel")
done < <(find "$REPO/.codex/roles" -type f -name "*.toml" -print0)
fi
# Gemini
[ -d "$REPO/.gemini/extensions/a11y-agents" ] && MANIFEST_ENTRIES+=("gemini/project") && MANIFEST_ENTRIES+=("gemini/global")
rm -rf "$TMPDIR_REPO"
echo " Built fallback manifest with ${#MANIFEST_ENTRIES[@]} entries."
else
rm -rf "$TMPDIR_REPO"
echo " Warning: Could not download repo for fallback. Will use file-pattern matching."
fi
fi
# ---------------------------------------------------------------------------
# Helper: remove our section markers from a config file.
# If no user content remains, delete the file. Otherwise keep user content.
# Returns: deleted | cleaned | skipped | absent
# ---------------------------------------------------------------------------
remove_our_section() {
local filepath="$1"
[ -f "$filepath" ] || { echo "absent"; return; }
local start end legacy_start legacy_end
case "$filepath" in
*.toml)
start="# a11y-agent-team: start"
end="# a11y-agent-team: end"
legacy_start="# accessibility-agents: start"
legacy_end="# accessibility-agents: end"
;;
*)
start="<!-- a11y-agent-team: start -->"
end="<!-- a11y-agent-team: end -->"
legacy_start="<!-- accessibility-agents: start -->"
legacy_end="<!-- accessibility-agents: end -->"
;;
esac
if grep -qF "$start" "$filepath" 2>/dev/null || grep -qF "$legacy_start" "$filepath" 2>/dev/null; then
if command -v python3 &>/dev/null; then
local result
result=$(A11Y_PATH="$filepath" A11Y_START="$start" A11Y_END="$end" A11Y_LEGACY_START="$legacy_start" A11Y_LEGACY_END="$legacy_end" python3 - << 'PYEOF'
import os, re
path = os.environ['A11Y_PATH']
start = os.environ['A11Y_START']
end = os.environ['A11Y_END']
legacy_start = os.environ.get('A11Y_LEGACY_START', '')
legacy_end = os.environ.get('A11Y_LEGACY_END', '')
content = open(path).read()
patterns = [re.escape(start) + r'.*?' + re.escape(end)]
if legacy_start and legacy_end:
patterns.append(re.escape(legacy_start) + r'.*?' + re.escape(legacy_end))
cleaned = re.sub(r'(?s)(?:' + '|'.join(patterns) + r')', '', content).strip()
if not cleaned:
os.remove(path)
print("deleted")
else:
open(path, 'w').write(cleaned + "\n")
print("cleaned")
PYEOF
)
echo "$result"
else
local start_count
start_count=$(grep -cF "$start" "$filepath" 2>/dev/null || echo 0)
if [ "$start_count" -gt 0 ]; then
echo "Warning: python3 unavailable — cannot safely remove our section from '$filepath'." >&2
echo "To remove manually: open the file and delete lines between '$start' and '$end'." >&2
echo "skipped"
else
echo "skipped"
fi
fi
else
echo "skipped"
fi
}
# =============================================
# 1. Remove Claude Code agents
# =============================================
echo ""
echo " Removing Claude Code agents..."
AGENTS_DIR="$TARGET_DIR/agents"
REMOVED_AGENTS=0
if [ -d "$AGENTS_DIR" ]; then
has_agent_entries=false
for entry in "${MANIFEST_ENTRIES[@]}"; do
case "$entry" in
agents/*)
has_agent_entries=true
agent_file="$TARGET_DIR/$entry"
if [ -f "$agent_file" ]; then
name="$(basename "${agent_file%.md}")"
rm "$agent_file"
echo " - $name"
REMOVED_AGENTS=$((REMOVED_AGENTS + 1))
fi
;;
esac
done
if [ "$has_agent_entries" = false ] && [ "$FALLBACK_USED" = true ]; then
# Last resort: remove all .md files in agents dir
for agent_file in "$AGENTS_DIR"/*.md; do
[ -f "$agent_file" ] || continue
name="$(basename "${agent_file%.md}")"
rm "$agent_file"
echo " - $name"
REMOVED_AGENTS=$((REMOVED_AGENTS + 1))
done
fi
fi
if [ "$REMOVED_AGENTS" -eq 0 ]; then
echo " (no agents found to remove)"
fi
# =============================================
# 2. Remove Copilot agents — project
# =============================================
if [ "$choice" = "1" ] && [ -n "$PROJECT_DIR" ]; then
COPILOT_DIR="$PROJECT_DIR/.github/agents"
if [ -d "$COPILOT_DIR" ]; then
echo ""
echo " Removing Copilot agents..."
has_copilot_entries=false
for entry in "${MANIFEST_ENTRIES[@]}"; do
case "$entry" in
copilot-agents/*)
has_copilot_entries=true
agent_name="${entry#copilot-agents/}"
agent_file="$COPILOT_DIR/$agent_name"
if [ -f "$agent_file" ]; then
name="$(basename "${agent_file%.md}")"
rm "$agent_file"
echo " - $name"
fi
;;
esac
done
if [ "$has_copilot_entries" = false ] && [ "$FALLBACK_USED" = true ]; then
for f in "$COPILOT_DIR"/*.agent.md; do
[ -f "$f" ] || continue
name="$(basename "${f%.agent.md}")"
rm "$f"
echo " - $name"
done
fi
rmdir "$COPILOT_DIR" 2>/dev/null || true
fi
# Remove Copilot config files — removes our section markers, preserves user content
GITHUB_DIR="$PROJECT_DIR/.github"
for config in copilot-instructions.md copilot-review-instructions.md copilot-commit-message-instructions.md; do
config_path="$GITHUB_DIR/$config"
result=$(remove_our_section "$config_path")
case "$result" in
deleted) echo " - $config" ;;
cleaned) echo " ~ $config (removed our section, kept your content)" ;;
esac
done
# Remove Copilot asset subdirs (skills, instructions, prompts)
for subdir in skills instructions prompts; do
asset_dir="$GITHUB_DIR/$subdir"
[ -d "$asset_dir" ] || continue
removed=0
for entry in "${MANIFEST_ENTRIES[@]}"; do
case "$entry" in
copilot-$subdir/*)
rel="${entry#copilot-$subdir/}"
target_file="$asset_dir/$rel"
if [ -f "$target_file" ]; then
rm "$target_file"
removed=$((removed + 1))
fi
;;
esac
done
# Clean up empty directories bottom-up
find "$asset_dir" -type d -empty -delete 2>/dev/null || true
[ "$removed" -gt 0 ] && echo " - $subdir/ ($removed files)"
done
fi
# =============================================
# 3. Remove Copilot agents — global
# =============================================
if [ "$choice" = "2" ]; then
while IFS='|' read -r profile_key profile_label profile_dir; do
[ -n "$profile_dir" ] || continue
[ -d "$profile_dir" ] || continue
prompts_dir="$profile_dir/prompts"
# Remove agent, prompt, and instruction files
for dir in "$profile_dir" "$prompts_dir"; do
[ -d "$dir" ] || continue
found=false
for pattern in "*.agent.md" "*.prompt.md" "*.instructions.md"; do
for f in "$dir"/$pattern; do
[ -f "$f" ] || continue
if [ "$found" = false ]; then
echo ""
echo " Removing files from: $dir"
found=true
fi
echo " - $(basename "$f")"
rm "$f"
done
done
done
# Remove prompts/ subdirectories that match our asset folders
for subfolder in skills instructions; do
subpath="$prompts_dir/$subfolder"
if [ -d "$subpath" ]; then
rm -rf "$subpath"
echo " - prompts/$subfolder/"
fi
done
# Restore settings.json — remove our chat.agentFilesLocations override
settings_file="$profile_dir/settings.json"
if [ -f "$settings_file" ] && command -v python3 &>/dev/null; then
A11Y_SF="$settings_file" python3 - << 'PYEOF' 2>/dev/null && echo " - Restored VS Code settings"
import json, os
sf = os.environ['A11Y_SF']
try:
with open(sf, 'r') as f:
s = json.load(f)
except:
exit(1)
loc = s.get('chat.agentFilesLocations', {})
changed = False
for key in ['.claude/agents', '.github/agents']:
if key in loc:
del loc[key]
changed = True
if not loc and 'chat.agentFilesLocations' in s:
del s['chat.agentFilesLocations']
changed = True
servers = s.get('mcp', {}).get('servers', {})
if 'a11y-agent-team' in servers:
del servers['a11y-agent-team']
changed = True
if not servers and 'servers' in s.get('mcp', {}):
del s['mcp']['servers']
if not s.get('mcp'):
del s['mcp']
if changed:
with open(sf, 'w') as f:
json.dump(s, f, indent=4)
else:
exit(1)
PYEOF
fi
done <<< "$SELECTED_VSCODE_PROFILES"
# Remove central Copilot store
COPILOT_CENTRAL="$HOME/.a11y-agent-team"
if [ -d "$COPILOT_CENTRAL" ]; then
echo ""
echo " Removing Copilot central store..."
rm -rf "$COPILOT_CENTRAL"
echo " - $COPILOT_CENTRAL"
fi
# Remove a11y-copilot-init from PATH (shell rc)
for rc_file in "$HOME/.zshrc" "$HOME/.bashrc"; do
if [ -f "$rc_file" ] && grep -q "a11y-copilot-init\|a11y-agent-team" "$rc_file" 2>/dev/null; then
if command -v python3 &>/dev/null; then
A11Y_RC="$rc_file" python3 - << 'PYEOF' 2>/dev/null
import os
rc = os.environ['A11Y_RC']
lines = open(rc).readlines()
cleaned = [l for l in lines if 'a11y-copilot-init' not in l and 'a11y-agent-team' not in l]
# Remove trailing blank lines left behind
while cleaned and cleaned[-1].strip() == '':
cleaned.pop()
cleaned.append('\n')
open(rc, 'w').writelines(cleaned)
PYEOF
echo " - Removed a11y-copilot-init from $rc_file"
else
echo " ! Could not clean $rc_file (python3 unavailable — remove manually)"
fi
fi
done
fi
# =============================================
# 4. Remove Codex CLI support
# =============================================
if [ "$choice" = "1" ]; then
CODEX_DIR="$(pwd)/.codex"
else
CODEX_DIR="$HOME/.codex"
fi
CODEX_FILE="$CODEX_DIR/AGENTS.md"
CODEX_CONFIG_FILE="$CODEX_DIR/config.toml"
if [ -f "$CODEX_FILE" ]; then
result=$(remove_our_section "$CODEX_FILE")
case "$result" in
deleted)
echo ""
echo " Removing Codex CLI support..."
rmdir "$CODEX_DIR" 2>/dev/null || true
echo " - AGENTS.md (Codex removed)"
;;
cleaned)
echo ""
echo " Codex CLI:"
echo " ~ AGENTS.md (removed our section, kept your content)"
;;
esac
fi
if [ -f "$CODEX_CONFIG_FILE" ]; then
result=$(remove_our_section "$CODEX_CONFIG_FILE")
case "$result" in
deleted)
echo ""
echo " Removing Codex experimental role config..."
echo " - config.toml (Codex role config removed)"
;;
cleaned)
echo ""
echo " Codex CLI:"
echo " ~ config.toml (removed our section, kept your content)"
;;
esac
fi
CODEX_ROLE_PATHS=()
for entry in "${MANIFEST_ENTRIES[@]}"; do
case "$entry" in
codex-config/path:*)
config_path="${entry#codex-config/path:}"
if [ -f "$config_path" ]; then
result=$(remove_our_section "$config_path")
case "$result" in
deleted) echo " - $(basename "$config_path") (removed)" ;;
cleaned) echo " ~ $(basename "$config_path") (removed our section, kept your content)" ;;
skipped) echo " ! $(basename "$config_path") (could not remove section — edit manually)" ;;
esac
fi
;;
codex-role/path:*)
CODEX_ROLE_PATHS+=("${entry#codex-role/path:}")
;;
codex/roles/*)
CODEX_ROLE_PATHS+=("$CODEX_DIR/${entry#codex/}")
;;
esac
done
for role_path in "${CODEX_ROLE_PATHS[@]}"; do
[ -f "$role_path" ] || continue
rm "$role_path"
echo " - $(basename "$role_path")"
done
if [ -d "$CODEX_DIR/roles" ]; then
find "$CODEX_DIR/roles" -type d -empty -delete 2>/dev/null || true
fi
rmdir "$CODEX_DIR" 2>/dev/null || true
# =============================================
# 5. Remove Gemini CLI extension
# =============================================
GEMINI_PATHS=()
# Check manifest for Gemini path
for entry in "${MANIFEST_ENTRIES[@]}"; do
case "$entry" in
gemini/path:*)
GEMINI_PATHS+=("${entry#gemini/path:}")
;;
esac
done
# Also check default locations
if [ "$choice" = "1" ]; then
GEMINI_PATHS+=("$(pwd)/.gemini/extensions/a11y-agents")
else
GEMINI_PATHS+=("$HOME/.gemini/extensions/a11y-agents")
fi
GEMINI_REMOVED=false
# Deduplicate paths (bash 3 compatible — no associative arrays)
_seen_paths=""
for gemini_dir in "${GEMINI_PATHS[@]}"; do
case "$_seen_paths" in *"|$gemini_dir|"*) continue ;; esac
_seen_paths="${_seen_paths}|${gemini_dir}|"
if [ -d "$gemini_dir" ]; then
echo ""
echo " Removing Gemini CLI extension..."
rm -rf "$gemini_dir"
echo " - $gemini_dir"
GEMINI_REMOVED=true
# Clean up empty parent dirs
parent="$(dirname "$gemini_dir")"
while [ -n "$parent" ] && [ -d "$parent" ] && [ -z "$(ls -A "$parent" 2>/dev/null)" ]; do
rmdir "$parent" 2>/dev/null || break
parent="$(dirname "$parent")"
done
fi
done
# =============================================
# 6. Remove Claude Code plugin (global only)
# =============================================
if [ "$choice" = "2" ]; then
plugins_json="$HOME/.claude/plugins/installed_plugins.json"
settings_json="$HOME/.claude/settings.json"
if [ -f "$plugins_json" ] && command -v python3 &>/dev/null; then
removed_key=$(python3 - "$plugins_json" << 'PYEOF'
import json, sys
path = sys.argv[1]
with open(path) as f:
data = json.load(f)
removed = None
for k in list(data.get('plugins', {})):
if k.startswith('a11y-agent-team@') or k.startswith('accessibility-agents@'):
removed = k
del data['plugins'][k]
break
with open(path, 'w') as f:
json.dump(data, f, indent=2)
if removed:
print(removed)
PYEOF
)
if [ -n "$removed_key" ]; then
echo ""
echo " Removing Claude Code plugin..."
echo " - Removed from installed_plugins.json ($removed_key)"
if [ -f "$settings_json" ]; then
python3 - "$settings_json" "$removed_key" << 'PYEOF'
import json, sys
path, key = sys.argv[1:3]
with open(path) as f:
data = json.load(f)
data.get('enabledPlugins', {}).pop(key, None)
with open(path, 'w') as f:
json.dump(data, f, indent=2)
PYEOF
echo " - Removed from settings.json enabledPlugins"
fi
# Remove plugin cache — key format is "name@namespace"
plugin_name="${removed_key%%@*}"
namespace="${removed_key#*@}"
cache_dir="$HOME/.claude/plugins/cache/${namespace}/${plugin_name}"
if [ -d "$cache_dir" ]; then
rm -rf "$cache_dir"
echo " - Removed plugin cache"
fi
ns_dir="$HOME/.claude/plugins/cache/${namespace}"
rmdir "$ns_dir" 2>/dev/null || true
fi
fi
fi
# =============================================
# 7. Remove enforcement hooks (global only)
# =============================================
if [ "$choice" = "2" ]; then
echo ""
echo " Removing enforcement hooks..."
for hook in a11y-team-eval.sh a11y-enforce-edit.sh a11y-mark-reviewed.sh; do
if [ -f "$HOME/.claude/hooks/$hook" ]; then
rm "$HOME/.claude/hooks/$hook"
echo " - $hook"
fi
done
rmdir "$HOME/.claude/hooks" 2>/dev/null || true
# Remove hook registrations from settings.json
if [ -f "$HOME/.claude/settings.json" ] && command -v python3 &>/dev/null; then
python3 - "$HOME/.claude/settings.json" << 'PYEOF'
import json, sys
path = sys.argv[1]
with open(path) as f:
data = json.load(f)
hooks = data.get("hooks", {})
changed = False
for event in list(hooks.keys()):
entries = hooks[event]
if isinstance(entries, list):
original = len(entries)
entries = [e for e in entries if not any(
"a11y-" in h.get("command", "")
for h in e.get("hooks", [])
)]
if len(entries) < original:
changed = True
if entries:
hooks[event] = entries
else:
del hooks[event]
changed = True
if changed:
if hooks:
data["hooks"] = hooks
else:
data.pop("hooks", None)
with open(path, "w") as f:
json.dump(data, f, indent=2)
PYEOF
echo " - Hook registrations removed from settings.json"
fi
# Clean up session markers
rm -f /tmp/a11y-reviewed-* 2>/dev/null || true
fi
# =============================================
# 8. Remove auto-update (global only)
# =============================================
if [ "$choice" = "2" ]; then
echo ""
echo " Removing auto-update..."
# Remove LaunchAgent (macOS)
for PLIST_FILE in \
"$HOME/Library/LaunchAgents/com.community-access.accessibility-agents-update.plist" \
"$HOME/Library/LaunchAgents/com.community-access.a11y-agent-team-update.plist"
do
if [ -f "$PLIST_FILE" ]; then
launchctl bootout "gui/$(id -u)" "$PLIST_FILE" 2>/dev/null || true
rm "$PLIST_FILE"
echo " - LaunchAgent removed ($PLIST_FILE)"
fi
done
# Remove cron job (Linux)
if crontab -l 2>/dev/null | grep -q "a11y-agent-team-update"; then
crontab -l 2>/dev/null | grep -v "a11y-agent-team-update" | crontab -
echo " - Cron job removed"
fi
# Remove update script, cache, version file, and log
rm -f "$TARGET_DIR/.a11y-agent-team-update.sh"
rm -f "$TARGET_DIR/.a11y-agent-team-version"
rm -f "$TARGET_DIR/.a11y-agent-team-update.log"
rm -rf "$TARGET_DIR/.a11y-agent-team-repo"
rm -f "$TARGET_DIR/.accessibility-agents-update.sh"
rm -f "$TARGET_DIR/.accessibility-agents-version"
rm -f "$TARGET_DIR/.accessibility-agents-update.log"
rm -rf "$TARGET_DIR/.accessibility-agents-repo"
echo " - Update files cleaned up"
fi
# =============================================
# 9. Clean up manifest and empty directories
# =============================================
rm -f "$MANIFEST_FILE"
rm -f "$TARGET_DIR/.a11y-agent-team-version"
rmdir "$TARGET_DIR/agents" 2>/dev/null || true
# =============================================
# Done
# =============================================
echo ""
echo " ========================="
echo " Uninstall complete!"
echo ""
echo " What was removed:"
echo " - Claude Code agents from $TARGET_DIR"
if [ "$choice" = "1" ]; then
echo " - Copilot agents, config, skills, instructions, prompts from .github/"
else
echo " - Copilot agents from VS Code profiles"
echo " - Copilot central store (~/.a11y-agent-team/)"
echo " - Claude Code plugin registration"
echo " - Enforcement hooks (3 hooks)"
fi
if [ "$GEMINI_REMOVED" = true ]; then
echo " - Gemini CLI extension"
fi
echo ""
echo " Next steps:"
echo " 1. Restart Claude Code, VS Code, and any open terminals"
echo " 2. Verify agents are gone: type '@' in Copilot Chat or '/agents' in Claude"
echo ""
echo " If something was missed, see the manual uninstall guide:"
echo " https://github.com/Community-Access/accessibility-agents/blob/main/UNINSTALL.md"
echo ""
write_summary_file "$SUMMARY_PATH" "{\"schemaVersion\":\"1.0\",\"timestampUtc\":\"$(date -u +%Y-%m-%dT%H:%M:%SZ)\",\"operation\":\"uninstall\",\"dryRun\":false,\"check\":false,\"scope\":\"$([ \"$choice\" = \"1\" ] && echo project || echo global)\",\"targetDir\":\"$(json_escape "$TARGET_DIR")\",\"requestedOptions\":{\"vscodeProfileMode\":\"$VSCODE_PROFILE_MODE\"},\"backupMetadataPath\":\"$(json_escape "$BACKUP_METADATA_PATH")\",\"notes\":[] }"
echo " Summary written to:"
echo " $SUMMARY_PATH"
echo ""