-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·3926 lines (3295 loc) · 120 KB
/
Copy pathsetup.sh
File metadata and controls
executable file
·3926 lines (3295 loc) · 120 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
#!/usr/bin/env bash
# AI Project Setup Script
# Automated setup for AI coding assistants with professional configurations
#
# Usage: ./setup.sh [options]
# Options:
# -h, --help Show this help message
# -v, --version Show version information
# --no-color Disable colored output
# --dry-run Show what would be done without making changes
# Enable strict mode for safer script execution
set -euo pipefail
IFS=$'\n\t'
# Script version and metadata
readonly SCRIPT_VERSION="2.0.0"
readonly SCRIPT_NAME="AI Project Setup Script"
# Global variables
ENABLE_COLOR=true
DRY_RUN=false
# Colors for output (only if terminal supports it)
if [[ -t 1 ]] && [[ "${ENABLE_COLOR}" == "true" ]]; then
readonly RED='\033[0;31m'
readonly GREEN='\033[0;32m'
readonly YELLOW='\033[1;33m'
readonly BLUE='\033[0;34m'
readonly PURPLE='\033[0;35m'
readonly CYAN='\033[0;36m'
readonly NC='\033[0m' # No Color
else
readonly RED=''
readonly GREEN=''
readonly YELLOW=''
readonly BLUE=''
readonly PURPLE=''
readonly CYAN=''
readonly NC=''
fi
# Function to print colored output
print_color() {
local color="$1"
local message="$2"
if [[ "${ENABLE_COLOR}" == "true" ]] && [[ -t 1 ]]; then
echo -e "${color}${message}${NC}"
else
echo "${message}"
fi
}
# Function to show usage information
usage() {
cat << EOF
${SCRIPT_NAME} v${SCRIPT_VERSION}
USAGE:
$0 [OPTIONS]
DESCRIPTION:
Automated setup script for AI coding assistants including GitHub Copilot,
Cline, Cursor, Windsurf, Augment, and Roo Code. Creates professional
configuration files, rules, and project structures.
OPTIONS:
-h, --help Show this help message and exit
-v, --version Show version information and exit
--no-color Disable colored output
--dry-run Show what would be done without making changes
--assistant Specify AI assistant (copilot|cline|cursor|windsurf|augment|roo)
EXAMPLES:
$0 # Interactive setup
$0 --assistant cursor # Setup Cursor only
$0 --dry-run # Preview changes without applying
$0 --no-color # Run without colored output
REQUIREMENTS:
- Bash 4.0 or higher
- Git (for project initialization)
- VS Code (optional, for extension installation)
For more information, visit: https://github.com/dazeb/ai-project-setup-script
EOF
}
# Function to show version information
show_version() {
echo "${SCRIPT_NAME} v${SCRIPT_VERSION}"
echo "Bash version: ${BASH_VERSION}"
echo "Platform: $(uname -s) $(uname -m)"
}
# Function to check if a command exists
command_exists() {
command -v "$1" >/dev/null 2>&1
}
# Function to check required dependencies
check_dependencies() {
local missing_deps=()
# Check for required commands
if ! command_exists "bash"; then
missing_deps+=("bash")
fi
# Check Bash version (require 4.0+)
if [[ "${BASH_VERSION%%.*}" -lt 4 ]]; then
print_color "${RED}" "Error: Bash 4.0 or higher is required. Current version: ${BASH_VERSION}"
exit 1
fi
# Check for optional but recommended commands
local optional_deps=("git" "curl" "code")
local missing_optional=()
for cmd in "${optional_deps[@]}"; do
if ! command_exists "$cmd"; then
missing_optional+=("$cmd")
fi
done
if [[ ${#missing_deps[@]} -gt 0 ]]; then
print_color "${RED}" "Error: Missing required dependencies:"
printf '%s\n' "${missing_deps[@]}"
exit 1
fi
if [[ ${#missing_optional[@]} -gt 0 ]]; then
print_color "${YELLOW}" "Warning: Missing optional dependencies (some features may be limited):"
printf '%s\n' "${missing_optional[@]}"
echo
fi
}
# Function to display ASCII art banner
show_banner() {
if [[ "${ENABLE_COLOR}" == "true" ]] && [[ -t 1 ]]; then
print_color "${CYAN}" "
╔═══════════════════════════════════════════════════════════════════════════════╗
║ ║
║ █████╗ ██╗ ██████╗ ██████╗ ██████╗ ██╗███████╗ ██████╗████████╗ ║
║ ██╔══██╗██║ ██╔══██╗██╔══██╗██╔═══██╗ ██║██╔════╝██╔════╝╚══██╔══╝ ║
║ ███████║██║ ██████╔╝██████╔╝██║ ██║ ██║█████╗ ██║ ██║ ║
║ ██╔══██║██║ ██╔═══╝ ██╔══██╗██║ ██║██ ██║██╔══╝ ██║ ██║ ║
║ ██║ ██║██║ ██║ ██║ ██║╚██████╔╝╚█████╔╝███████╗╚██████╗ ██║ ║
║ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚════╝ ╚══════╝ ╚═════╝ ╚═╝ ║
║ ║
║ ███████╗███████╗████████╗██╗ ██╗██████╗ ║
║ ██╔════╝██╔════╝╚══██╔══╝██║ ██║██╔══██╗ ║
║ ███████╗█████╗ ██║ ██║ ██║██████╔╝ ║
║ ╚════██║██╔══╝ ██║ ██║ ██║██╔═══╝ ║
║ ███████║███████╗ ██║ ╚██████╔╝██║ ║
║ ╚══════╝╚══════╝ ╚═╝ ╚═════╝ ╚═╝ ║
║ ║
╚═══════════════════════════════════════════════════════════════════════════════╝"
echo
print_color "${GREEN}" " 🤖 AI-Powered Development Environment Setup"
print_color "${YELLOW}" " Professional Configuration for AI Assistants"
print_color "${PURPLE}" " Version ${SCRIPT_VERSION}"
echo
else
echo "=============================================================================="
echo " AI PROJECT SETUP"
echo " Professional Configuration for AI Assistants"
echo " Version ${SCRIPT_VERSION}"
echo "=============================================================================="
echo
fi
}
# Function to print section headers
print_header() {
echo
print_color "${CYAN}" "============================================"
print_color "${CYAN}" "$1"
print_color "${CYAN}" "============================================"
echo
}
# Function to parse command line arguments
parse_arguments() {
while [[ $# -gt 0 ]]; do
case $1 in
-h|--help)
usage
exit 0
;;
-v|--version)
show_version
exit 0
;;
--no-color)
ENABLE_COLOR=false
shift
;;
--dry-run)
DRY_RUN=true
shift
;;
--assistant)
if [[ -n "${2:-}" ]]; then
AI_ASSISTANT="$2"
shift 2
else
print_color "${RED}" "Error: --assistant requires a value"
exit 1
fi
;;
*)
print_color "${RED}" "Error: Unknown option '$1'"
echo "Use '$0 --help' for usage information."
exit 1
;;
esac
done
}
# Function to confirm destructive actions
confirm_action() {
local message="$1"
local default="${2:-n}"
if [[ "${DRY_RUN}" == "true" ]]; then
print_color "${BLUE}" "[DRY RUN] Would ask: ${message}"
return 0
fi
local prompt
if [[ "${default}" == "y" ]]; then
prompt="${message} [Y/n] "
else
prompt="${message} [y/N] "
fi
read -p "${prompt}" response
response="${response:-${default}}"
[[ "${response}" =~ ^[Yy]$ ]]
}
# Utility function for safe directory creation
safe_mkdir() {
local dirs=("$@")
if [[ "${DRY_RUN}" == "true" ]]; then
print_color "${BLUE}" "[DRY RUN] Would create directories: ${dirs[*]}"
return 0
fi
for dir in "${dirs[@]}"; do
if [[ -z "${dir}" ]]; then
print_color "${RED}" "Error: Empty directory name provided"
return 1
fi
if ! mkdir -p "${dir}"; then
print_color "${RED}" "Failed to create directory: ${dir}"
return 1
fi
print_color "${GREEN}" "Created directory: ${dir}"
done
}
# Utility function for safe file creation
create_file() {
local filepath="$1"
local content="$2"
if [[ -z "${filepath}" ]]; then
print_color "${RED}" "Error: Empty filepath provided"
return 1
fi
if [[ "${DRY_RUN}" == "true" ]]; then
print_color "${BLUE}" "[DRY RUN] Would create file: ${filepath}"
return 0
fi
# Ensure directory exists
local dir
dir="$(dirname "${filepath}")"
if [[ ! -d "${dir}" ]]; then
safe_mkdir "${dir}" || return 1
fi
if ! echo "${content}" > "${filepath}"; then
print_color "${RED}" "Failed to create file: ${filepath}"
return 1
fi
print_color "${GREEN}" "Created file: ${filepath}"
}
# Utility function for creating rule files with error handling
create_rule_file() {
local filepath="$1"
local content="$2"
if [[ -z "${filepath}" || -z "${content}" ]]; then
print_color "${RED}" "Error: filepath and content are required for create_rule_file"
return 1
fi
if [[ "${DRY_RUN}" == "true" ]]; then
print_color "${BLUE}" "[DRY RUN] Would create rule file: ${filepath}"
return 0
fi
# Ensure directory exists
local dir
dir="$(dirname "${filepath}")"
safe_mkdir "${dir}" || return 1
# Create file with content using a more robust method
if ! cat > "${filepath}" << EOF
${content}
EOF
then
print_color "${RED}" "Failed to create rule file: ${filepath}"
return 1
fi
print_color "${GREEN}" "Created rule file: ${filepath}"
}
# Utility function for copying files with error handling
safe_copy() {
local source="$1"
local destination="$2"
if [[ -z "${source}" || -z "${destination}" ]]; then
print_color "${RED}" "Error: source and destination are required for safe_copy"
return 1
fi
if [[ "${DRY_RUN}" == "true" ]]; then
print_color "${BLUE}" "[DRY RUN] Would copy ${source} to ${destination}"
return 0
fi
if [[ -f "${source}" ]]; then
# Ensure destination directory exists
local dest_dir
dest_dir="$(dirname "${destination}")"
safe_mkdir "${dest_dir}" || return 1
if cp "${source}" "${destination}" 2>/dev/null; then
print_color "${GREEN}" "Copied ${source} to ${destination}"
else
print_color "${YELLOW}" "Warning: Failed to copy ${source} to ${destination}"
return 1
fi
else
print_color "${YELLOW}" "Warning: Source file ${source} does not exist"
return 1
fi
}
# Utility function for automatic global rules placement
place_global_rules() {
local assistant_name="$1"
local rules_content="$2"
local global_path="$3"
if [[ -z "${assistant_name}" || -z "${rules_content}" || -z "${global_path}" ]]; then
print_color "${RED}" "Error: All parameters are required for place_global_rules"
return 1
fi
if [[ -f "${global_path}" ]]; then
print_color "${YELLOW}" "Global rules already exist at ${global_path}. Skipping to avoid overwrite."
return 0
fi
if [[ "${DRY_RUN}" == "true" ]]; then
print_color "${BLUE}" "[DRY RUN] Would create global rules for ${assistant_name} at ${global_path}"
return 0
fi
safe_mkdir "$(dirname "${global_path}")" || return 1
create_rule_file "${global_path}" "${rules_content}" || return 1
print_color "${GREEN}" "Global rules template created for ${assistant_name} at ${global_path}"
}
# Function to copy TypeScript/React rule files if they exist
copy_typescript_react_rules() {
local script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
local src_dir="$script_dir/src"
# Copy TypeScript, ShadCN UI, and Tailwind CSS rules if they exist
if [[ -f "$src_dir/typescript.mdc" ]]; then
print_color $YELLOW "Adding TypeScript rules..."
cp "$src_dir/typescript.mdc" .cursor/rules/ 2>/dev/null || true
cp "$src_dir/typescript.mdc" .windsurf/rules/ 2>/dev/null || true
# Convert MDC to markdown for other AI assistants
sed '1,/^---$/d; /^---$/,$d' "$src_dir/typescript.mdc" > .clinerules/typescript-rules.md 2>/dev/null || true
sed '1,/^---$/d; /^---$/,$d' "$src_dir/typescript.mdc" > .augment/rules/typescript-rules.md 2>/dev/null || true
sed '1,/^---$/d; /^---$/,$d' "$src_dir/typescript.mdc" > .roo/rules-code/typescript-rules.md 2>/dev/null || true
fi
if [[ -f "$src_dir/shadcn-ui.mdc" ]]; then
print_color $YELLOW "Adding ShadCN UI component rules..."
cp "$src_dir/shadcn-ui.mdc" .cursor/rules/ 2>/dev/null || true
cp "$src_dir/shadcn-ui.mdc" .windsurf/rules/ 2>/dev/null || true
# Convert MDC to markdown for other AI assistants
sed '1,/^---$/d; /^---$/,$d' "$src_dir/shadcn-ui.mdc" > .clinerules/shadcn-ui-components.md 2>/dev/null || true
sed '1,/^---$/d; /^---$/,$d' "$src_dir/shadcn-ui.mdc" > .augment/rules/shadcn-ui-components.md 2>/dev/null || true
sed '1,/^---$/d; /^---$/,$d' "$src_dir/shadcn-ui.mdc" > .roo/rules-code/shadcn-ui-components.md 2>/dev/null || true
fi
if [[ -f "$src_dir/tailwind.mdc" ]]; then
print_color $YELLOW "Adding Tailwind CSS rules..."
cp "$src_dir/tailwind.mdc" .cursor/rules/ 2>/dev/null || true
cp "$src_dir/tailwind.mdc" .windsurf/rules/ 2>/dev/null || true
# Convert MDC to markdown for other AI assistants
sed '1,/^---$/d; /^---$/,$d' "$src_dir/tailwind.mdc" > .clinerules/tailwind-css-rules.md 2>/dev/null || true
sed '1,/^---$/d; /^---$/,$d' "$src_dir/tailwind.mdc" > .augment/rules/tailwind-css-rules.md 2>/dev/null || true
sed '1,/^---$/d; /^---$/,$d' "$src_dir/tailwind.mdc" > .roo/rules-code/tailwind-css-rules.md 2>/dev/null || true
fi
print_color $GREEN "TypeScript/React rules added successfully!"
}
# Function to setup VS Code workspace with MCP configuration
setup_vscode_workspace() {
print_color $YELLOW "Setting up VS Code workspace configuration..."
# Create workspace settings directory
mkdir -p .vscode
# Create VS Code settings with MCP and AI assistant configuration
cat > .vscode/settings.json << 'EOF'
{
"github.copilot.enable": {
"*": true,
"yaml": true,
"plaintext": true,
"markdown": true
},
"github.copilot.chat.codeGeneration.useInstructionFiles": true,
"github.copilot.chat.reviewSelection.instructions": [
{ "text": "Focus on code quality, security vulnerabilities, and performance issues." },
{ "text": "Provide specific suggestions for improvement with examples." }
],
"github.copilot.chat.commitMessageGeneration.instructions": [
{ "text": "Use conventional commit format (feat:, fix:, docs:, etc.)" },
{ "text": "Keep the first line under 50 characters" },
{ "text": "Include a detailed description if the change is complex" }
],
"chat.promptFiles": true,
"chat.instructionsFilesLocations": {
".github/instructions": true,
"docs/instructions": true
},
"chat.promptFilesLocations": {
".github/prompts": true,
"docs/prompts": true
},
"files.associations": {
"*.mcp": "json",
"mcp.json": "json"
},
"json.schemas": [
{
"fileMatch": ["mcp.json", "*.mcp"],
"url": "https://raw.githubusercontent.com/modelcontextprotocol/specification/main/schema/mcp.schema.json"
}
]
}
EOF
# Create MCP configuration for AI tools
cat > .vscode/mcp.json << 'EOF'
{
"$schema": "https://raw.githubusercontent.com/modelcontextprotocol/specification/main/schema/mcp.schema.json",
"name": "Project MCP Configuration",
"version": "1.0.0",
"description": "Model Context Protocol configuration for AI assistants",
"tools": [
{
"name": "file_reader",
"description": "Read and analyze project files",
"parameters": {
"type": "object",
"properties": {
"path": {
"type": "string",
"description": "File path to read"
}
},
"required": ["path"]
}
},
{
"name": "code_analyzer",
"description": "Analyze code structure and patterns",
"parameters": {
"type": "object",
"properties": {
"language": {
"type": "string",
"description": "Programming language"
},
"file_path": {
"type": "string",
"description": "Path to code file"
}
},
"required": ["language", "file_path"]
}
},
{
"name": "project_structure",
"description": "Analyze and understand project structure",
"parameters": {
"type": "object",
"properties": {
"root_path": {
"type": "string",
"description": "Project root directory"
}
},
"required": ["root_path"]
}
},
{
"name": "documentation_generator",
"description": "Generate documentation for code and APIs",
"parameters": {
"type": "object",
"properties": {
"type": {
"type": "string",
"enum": ["api", "readme", "inline", "architecture"],
"description": "Type of documentation to generate"
},
"target": {
"type": "string",
"description": "Target file or component"
}
},
"required": ["type", "target"]
}
},
{
"name": "test_generator",
"description": "Generate unit and integration tests",
"parameters": {
"type": "object",
"properties": {
"test_type": {
"type": "string",
"enum": ["unit", "integration", "e2e"],
"description": "Type of test to generate"
},
"target_file": {
"type": "string",
"description": "File to generate tests for"
},
"framework": {
"type": "string",
"description": "Testing framework to use"
}
},
"required": ["test_type", "target_file"]
}
},
{
"name": "code_refactor",
"description": "Refactor code following best practices",
"parameters": {
"type": "object",
"properties": {
"refactor_type": {
"type": "string",
"enum": ["extract_function", "rename", "optimize", "modernize"],
"description": "Type of refactoring to perform"
},
"target": {
"type": "string",
"description": "Code section to refactor"
}
},
"required": ["refactor_type", "target"]
}
},
{
"name": "security_analyzer",
"description": "Analyze code for security vulnerabilities",
"parameters": {
"type": "object",
"properties": {
"scan_type": {
"type": "string",
"enum": ["full", "dependencies", "code", "config"],
"description": "Type of security scan"
},
"severity": {
"type": "string",
"enum": ["low", "medium", "high", "critical"],
"description": "Minimum severity level"
}
},
"required": ["scan_type"]
}
}
],
"resources": [
{
"name": "project_files",
"description": "Access to project source files",
"uri": "file://./src/**/*"
},
{
"name": "documentation",
"description": "Access to project documentation",
"uri": "file://./docs/**/*"
},
{
"name": "tests",
"description": "Access to test files",
"uri": "file://./tests/**/*"
},
{
"name": "config_files",
"description": "Access to configuration files",
"uri": "file://./*.json"
}
],
"prompts": [
{
"name": "code_review",
"description": "Perform comprehensive code review",
"arguments": [
{
"name": "file_path",
"description": "Path to file for review",
"required": true
}
]
},
{
"name": "explain_code",
"description": "Explain code functionality and patterns",
"arguments": [
{
"name": "code_section",
"description": "Code section to explain",
"required": true
}
]
},
{
"name": "generate_tests",
"description": "Generate comprehensive test suite",
"arguments": [
{
"name": "target_file",
"description": "File to generate tests for",
"required": true
},
{
"name": "test_framework",
"description": "Testing framework preference",
"required": false
}
]
},
{
"name": "optimize_performance",
"description": "Analyze and optimize code performance",
"arguments": [
{
"name": "target",
"description": "Code or component to optimize",
"required": true
}
]
}
]
}
EOF
# Create VS Code tasks for common development workflows
cat > .vscode/tasks.json << 'EOF'
{
"version": "2.0.0",
"tasks": [
{
"label": "AI: Code Review",
"type": "shell",
"command": "echo",
"args": ["Triggering AI code review..."],
"group": "build",
"presentation": {
"echo": true,
"reveal": "always",
"focus": false,
"panel": "shared"
},
"problemMatcher": []
},
{
"label": "AI: Generate Tests",
"type": "shell",
"command": "echo",
"args": ["Triggering AI test generation..."],
"group": "test",
"presentation": {
"echo": true,
"reveal": "always",
"focus": false,
"panel": "shared"
},
"problemMatcher": []
},
{
"label": "AI: Generate Documentation",
"type": "shell",
"command": "echo",
"args": ["Triggering AI documentation generation..."],
"group": "build",
"presentation": {
"echo": true,
"reveal": "always",
"focus": false,
"panel": "shared"
},
"problemMatcher": []
},
{
"label": "AI: Security Scan",
"type": "shell",
"command": "echo",
"args": ["Triggering AI security analysis..."],
"group": "build",
"presentation": {
"echo": true,
"reveal": "always",
"focus": false,
"panel": "shared"
},
"problemMatcher": []
}
]
}
EOF
# Create launch configuration for debugging
cat > .vscode/launch.json << 'EOF'
{
"version": "0.2.0",
"configurations": [
{
"name": "Debug with AI Assistant",
"type": "node",
"request": "launch",
"program": "${workspaceFolder}/src/index.js",
"console": "integratedTerminal",
"env": {
"NODE_ENV": "development"
},
"preLaunchTask": "AI: Code Review"
}
]
}
EOF
print_color $GREEN "VS Code workspace configured with MCP tools and AI assistant integration!"
}
# Function to ask user for AI coding assistant preference
ask_ai_assistant() {
print_color "${YELLOW}" "Which AI coding assistant are you using?"
echo "1) GitHub Copilot"
echo "2) Cline (formerly Claude Dev)"
echo "3) Roo Code"
echo "4) Cursor"
echo "5) Augment"
echo "6) Windsurf"
echo "7) None / Skip AI setup"
echo
while true; do
read -p "Please enter your choice (1-7): " choice
case $choice in
1)
AI_ASSISTANT="github-copilot"
break
;;
2)
AI_ASSISTANT="cline"
break
;;
3)
AI_ASSISTANT="roo-code"
break
;;
4)
AI_ASSISTANT="cursor"
break
;;
5)
AI_ASSISTANT="augment"
break
;;
6)
AI_ASSISTANT="windsurf"
break
;;
7)
AI_ASSISTANT="none"
break
;;
*)
print_color $RED "Invalid choice. Please enter a number between 1-7."
;;
esac
done
print_color $GREEN "Selected: $AI_ASSISTANT"
}
# Function to setup GitHub Copilot
setup_github_copilot() {
print_header "Setting up GitHub Copilot"
# Install GitHub Copilot extension if VS Code is available
if command -v code &> /dev/null; then
print_color "$YELLOW" "Installing GitHub Copilot extension..."
code --install-extension GitHub.copilot
code --install-extension GitHub.copilot-chat
else
print_color "$YELLOW" "VS Code not found. Extensions will need to be installed manually."
fi
# Consolidated directory creation
print_color "$YELLOW" "Creating GitHub Copilot directory structure..."
safe_mkdir \
.github \
.github/instructions \
.github/prompts
# Create workspace settings directory
setup_vscode_workspace
# Copy TypeScript/React rules
copy_typescript_react_rules
# Create GitHub Copilot instructions using utility functions
print_color "$YELLOW" "Creating GitHub Copilot instructions..."
create_rule_file ".github/copilot-instructions.md" '# Project Coding Standards
## General Guidelines
- Write clean, readable, and maintainable code
- Follow the existing code style and patterns in the project
- Add meaningful comments for complex logic
- Use descriptive variable and function names
- Prefer composition over inheritance
- Write tests for new functionality
## Code Quality
- Handle errors gracefully with proper error messages
- Validate input parameters
- Use appropriate data structures for the task
- Optimize for readability first, performance second
- Follow SOLID principles where applicable
## Documentation
- Update README.md when adding new features
- Document public APIs and complex functions
- Include usage examples in documentation
- Keep documentation up to date with code changes
## Security
- Sanitize user inputs
- Use secure coding practices
- Avoid hardcoding sensitive information
- Follow principle of least privilege
- Validate and escape data appropriately
## Testing
- Write unit tests for new functions
- Include edge cases in tests
- Use descriptive test names
- Mock external dependencies
- Aim for good test coverage'
create_rule_file ".github/instructions/typescript.instructions.md" '---
applyTo: "**/*.ts,**/*.tsx"
description: "TypeScript and React coding guidelines"
---
# TypeScript and React Guidelines
## TypeScript Best Practices
- Use strict TypeScript configuration
- Prefer interfaces over types for object shapes
- Use union types for controlled values
- Implement proper error handling with Result types
- Use generic types for reusable components
- Prefer readonly arrays and objects when possible
## React Guidelines
- Use functional components with hooks
- Follow React hooks rules (no conditional hooks)
- Use React.FC type for components with children
- Keep components small and focused (single responsibility)
- Use proper key props for lists
- Implement proper error boundaries
- Use CSS modules or styled-components for styling
## Naming Conventions
- Use PascalCase for component names and interfaces
- Use camelCase for variables, functions, and methods
- Use UPPER_SNAKE_CASE for constants
- Prefix custom hooks with 'use'
- Use descriptive names that explain purpose'
cat > .github/instructions/python.instructions.md << 'EOF'
---
applyTo: "**/*.py"
description: "Python coding guidelines"
---
# Python Guidelines
## Code Style
- Follow PEP 8 style guide
- Use type hints for function parameters and return values
- Use docstrings for modules, classes, and functions
- Prefer list comprehensions over loops when readable
- Use f-strings for string formatting
- Keep line length under 88 characters (Black formatter)
## Best Practices
- Use virtual environments for dependencies
- Handle exceptions specifically, avoid bare except
- Use context managers (with statements) for resource management
- Prefer pathlib over os.path for file operations
- Use dataclasses or Pydantic models for structured data
- Follow the principle of least surprise
## Testing
- Use pytest for testing
- Write descriptive test function names
- Use fixtures for test setup
- Mock external dependencies
- Test edge cases and error conditions
EOF
# Create prompts directory and sample files
mkdir -p .github/prompts
cat > .github/prompts/code-review.prompt.md << 'EOF'
---
mode: 'ask'
description: 'Perform a comprehensive code review'
---
Please perform a comprehensive code review of the selected code. Focus on:
## Code Quality
- Code readability and maintainability
- Adherence to coding standards and best practices
- Proper error handling and edge cases
- Performance considerations
## Security
- Input validation and sanitization
- Potential security vulnerabilities
- Proper authentication and authorization
- Data protection and privacy concerns
## Architecture
- Code organization and structure
- Separation of concerns
- Dependency management
- Scalability considerations
## Testing
- Test coverage and quality
- Missing test cases
- Test maintainability
Please provide specific, actionable feedback with examples where possible.
EOF
cat > .github/prompts/generate-tests.prompt.md << 'EOF'
---
mode: 'agent'